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

Categorize as gc #67

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions ext/vernier/vernier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ class RawSample {
return;
}

if (rb_during_gc()) {
if (false && rb_during_gc()) {
gc = true;
} else {
len = rb_profile_frames(0, MAX_LEN, frames, lines);
Expand Down Expand Up @@ -958,7 +958,8 @@ class GCMarkerTable: public MarkerTable {
enum Category{
CATEGORY_NORMAL,
CATEGORY_IDLE,
CATEGORY_STALLED
CATEGORY_STALLED,
CATEGORY_GC
};

class ObjectSampleList {
Expand Down Expand Up @@ -1630,6 +1631,8 @@ class TimeCollector : public BaseCollector {
unsigned int allocation_sample_rate;
unsigned int allocation_sample_tick = 0;

atomic_bool gc_running;

VALUE tp_newobj = Qnil;

static void newobj_i(VALUE tpval, void *data) {
Expand Down Expand Up @@ -1667,7 +1670,10 @@ class TimeCollector : public BaseCollector {
BaseCollector::write_meta(meta, result);
rb_hash_aset(meta, sym("interval"), ULL2NUM(interval.microseconds()));
rb_hash_aset(meta, sym("allocation_sample_rate"), ULL2NUM(allocation_sample_rate));
}

void set_gc_running(bool value) {
gc_running = value;
}

private:
Expand Down Expand Up @@ -1730,7 +1736,7 @@ class TimeCollector : public BaseCollector {
} else if (sample.sample.empty()) {
// fprintf(stderr, "skipping GC sample\n");
} else {
record_sample(sample.sample, sample_start, thread, CATEGORY_NORMAL);
record_sample(sample.sample, sample_start, thread, gc_running ? CATEGORY_GC : CATEGORY_NORMAL);
}
} else if (thread.state == Thread::State::SUSPENDED) {
thread.samples.record_sample(
Expand Down Expand Up @@ -1803,9 +1809,11 @@ class TimeCollector : public BaseCollector {
collector->gc_markers.record_gc_end_sweep();
break;
case RUBY_INTERNAL_EVENT_GC_ENTER:
collector->set_gc_running(true);
collector->gc_markers.record_gc_entered();
break;
case RUBY_INTERNAL_EVENT_GC_EXIT:
collector->set_gc_running(false);
collector->gc_markers.record_gc_leave();
break;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/vernier/output/firefox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def initialize
add_category(name: "Idle", color: "transparent")
add_category(name: "Stalled", color: "transparent")

add_category(name: "GC", color: "red")
add_category(name: "GC", color: "orange")
add_category(name: "cfunc", color: "yellow", matcher: "<cfunc>")

add_category(name: "Thread", color: "grey")
Expand Down
Loading