Skip to content

Commit

Permalink
Merge pull request #214 from tmm1/fix-gc-times
Browse files Browse the repository at this point in the history
Fix GC profiling timing
  • Loading branch information
tenderlove authored Jul 12, 2023
2 parents 51b71bf + 329e57b commit 726a172
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ext/stackprof/stackprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ static struct {
size_t unrecorded_gc_sweeping_samples;
st_table *frames;

timestamp_t gc_start_timestamp;

VALUE fake_frame_names[TOTAL_FAKE_FRAMES];
VALUE empty_string;

Expand Down Expand Up @@ -646,15 +648,15 @@ stackprof_buffer_sample(void)
_stackprof.buffer_time.delta_usec = timestamp_delta;
}

// Postponed job
void
stackprof_record_gc_samples(void)
{
int64_t delta_to_first_unrecorded_gc_sample = 0;
uint64_t start_timestamp = 0;
size_t i;
if (_stackprof.raw) {
struct timestamp_t t;
capture_timestamp(&t);
struct timestamp_t t = _stackprof.gc_start_timestamp;
start_timestamp = timestamp_usec(&t);

// We don't know when the GC samples were actually marked, so let's
Expand Down Expand Up @@ -776,6 +778,10 @@ stackprof_signal_handler(int sig, siginfo_t *sinfo, void *ucontext)
} else if (mode == sym_sweeping) {
_stackprof.unrecorded_gc_sweeping_samples++;
}
if(!_stackprof.unrecorded_gc_samples) {
// record start
capture_timestamp(&_stackprof.gc_start_timestamp);
}
_stackprof.unrecorded_gc_samples++;
rb_postponed_job_register_one(0, stackprof_job_record_gc, (void*)0);
} else {
Expand Down

0 comments on commit 726a172

Please sign in to comment.