From 697f27ea96baec5d71ac2912191fceb355574b6b Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Sat, 6 Jul 2024 11:57:46 -0700 Subject: [PATCH 1/3] Categorize as GC --- ext/vernier/vernier.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ext/vernier/vernier.cc b/ext/vernier/vernier.cc index 0a19d05..5724621 100644 --- a/ext/vernier/vernier.cc +++ b/ext/vernier/vernier.cc @@ -958,7 +958,8 @@ class GCMarkerTable: public MarkerTable { enum Category{ CATEGORY_NORMAL, CATEGORY_IDLE, - CATEGORY_STALLED + CATEGORY_STALLED, + CATEGORY_GC }; class ObjectSampleList { @@ -1624,6 +1625,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) { @@ -1661,7 +1664,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: @@ -1724,7 +1730,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( @@ -1797,9 +1803,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; } From 4945e37a1b0098f88f62c4c3daec3df5ce2772fa Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Sun, 28 Apr 2024 18:13:23 -0700 Subject: [PATCH 2/3] GC is orange --- lib/vernier/output/firefox.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vernier/output/firefox.rb b/lib/vernier/output/firefox.rb index 519b4cf..7c000d3 100644 --- a/lib/vernier/output/firefox.rb +++ b/lib/vernier/output/firefox.rb @@ -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: "") add_category(name: "Thread", color: "grey") From 64a0a9be09add52bacdef23ee43b03976f4be252 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Mon, 29 Apr 2024 00:18:45 -0700 Subject: [PATCH 3/3] WIP --- ext/vernier/vernier.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/vernier/vernier.cc b/ext/vernier/vernier.cc index 5724621..dbe811f 100644 --- a/ext/vernier/vernier.cc +++ b/ext/vernier/vernier.cc @@ -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);