Skip to content

Commit

Permalink
Profile based on Ruby thread rather than native thread (#46)
Browse files Browse the repository at this point in the history
* Record samples by Ruby thread not native thread

Previously would collect samples grouping them my native thread id. This
worked relatively well, and was a somewhat arbitrary choice.

Ruby 3.3 will have a M-N thread scheduler, which means that a single
native thread may run multiple Ruby threads, and threads may migrate
between native threads. With this profiles should be much more readable
and useful if separated by Ruby thread.

Co-authored-by: Aaron Patterson <[email protected]>
Co-authored-by: John Hawthorn <[email protected]>
Co-authored-by: Danny <[email protected]>
  • Loading branch information
3 people authored Dec 7, 2023
1 parent 02b0fc5 commit 02d7b58
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 76 deletions.
2 changes: 2 additions & 0 deletions exe/vernier
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ end
vernier_path = File.expand_path('../lib', __dir__)
env['RUBYOPT'] = "-I #{vernier_path} -r vernier/autorun #{ENV['RUBYOPT']}"

ARGV.unshift("gdb", "--args")

Kernel.exec(env, *ARGV)
5 changes: 5 additions & 0 deletions ext/vernier/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@
$CXXFLAGS += " -std=c++14 "
$CXXFLAGS += " -ggdb3 -Og "

have_header("ruby/thread.h")
have_struct_member("rb_internal_thread_event_data_t", "thread", ["ruby/thread.h"])

have_func("rb_profile_thread_frames", "ruby/debug.h")

create_makefile("vernier/vernier")
Loading

0 comments on commit 02d7b58

Please sign in to comment.