Skip to content

Conversation

@rwstauner
Copy link
Contributor

Auto install the gems outside of any gems the benchmark might require.
Save the file to the data dir and show a report when finished.

I've been using this to get allocation info:

$ STACKPROF_OPTS='mode:object' MIN_BENCH_TIME=1 MIN_BENCH_ITRS=1 RBENV_VERSION=ruby-master ruby -v -I harness-stackprof benchmarks/protoboeuf-encode/benchmark.rb
ruby 3.4.0dev (2024-08-01T19:54:08Z master f6e829603e) [arm64-darwin23]
Adding to load path: /Users/rwstauner/.rubies/ruby-master/lib/ruby/gems/3.4.0+0/gems/stackprof-0.2.26/lib
==================================
  Mode: object(1)
  Samples: 175 (0.00% miss rate)
  GC: 0 (0.00%)
==================================
     TOTAL    (pct)     SAMPLES    (pct)     FRAME
       132  (75.4%)         132  (75.4%)     String#+@
        12   (6.9%)          12   (6.9%)     #<Object:0x0000000104a4ed68>.fetch
       174  (99.4%)           8   (4.6%)     Object#run_enough_to_profile
         7   (4.0%)           6   (3.4%)     ProtoBoeuf::ParkingSpace#_encode
       149  (85.1%)           4   (2.3%)     ProtoBoeuf::ParkingLot.encode
         3   (1.7%)           3   (1.7%)     Object#get_time
        11   (6.3%)           3   (1.7%)     ProtoBoeuf::ParkingFloor#_encode
       151  (86.3%)           2   (1.1%)     block (2 levels) in <main>
        13   (7.4%)           2   (1.1%)     ProtoBoeuf::ParkingLot#_encode
         1   (0.6%)           1   (0.6%)     ProtoBoeuf::Vehicle#_encode
         1   (0.6%)           1   (0.6%)     BasicObject#!=
       175 (100.0%)           1   (0.6%)     Object#run_benchmark
       151  (86.3%)           0   (0.0%)     Integer#times
       151  (86.3%)           0   (0.0%)     block in <main>
       151  (86.3%)           0   (0.0%)     Array#each
       168  (96.0%)           0   (0.0%)     Kernel#loop
       175 (100.0%)           0   (0.0%)     <main>
       175 (100.0%)           0   (0.0%)     StackProf.run
Stackprof dump file:
/Users/rwstauner/src/github.com/Shopify/yjit-bench/data/stackprof-object-2024-08-01-155820-ruby-3.4.0-protoboeuf-encode.dump

You can then run further stackprof analysis on the file shown at the end.

Auto install the gems outside of any gems the benchmark might require.
Save the file to the data dir and show a report when finished.
Comment on lines 14 to 22
BOOLS = {"true" => true, "false" => false}
def bool!(val)
case val
when TrueClass, FalseClass
val
else
BOOLS.fetch(val) { raise ArgumentError, "must be 'true' or 'false'" }
end
end
Copy link
Contributor

@maximecb maximecb Aug 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good initiative. However, I feel like the code you write (in general) could use more commenting. I'll try to give some specific examples.

Can you add a comment here explaining what this method is used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right. I'm accustomed to having to read the code to figure out what it's actually doing, but I shouldn't make other people do the same :)

@rwstauner
Copy link
Contributor Author

rwstauner commented Aug 2, 2024

Does that seem like a good level of commenting?
I want it to be helpful without being too much to read or too likely to become out of date.

@maximecb
Copy link
Contributor

maximecb commented Aug 2, 2024

Does that seem like a good level of commenting? I want it to be helpful without being too much to read or too likely to become out of date.

Sure this seems good. Thank you :)

@maximecb maximecb merged commit c4077b3 into main Aug 2, 2024
@maximecb maximecb deleted the rwstauner/profiling-harnesses branch August 2, 2024 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants