Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GC profiling timing #214

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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