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

YJIT: Add top ISEQ call counts to --yjit-stats #9906

Merged
merged 2 commits into from
Feb 9, 2024

Conversation

k0kubun
Copy link
Member

@k0kubun k0kubun commented Feb 9, 2024

This is the same as #9047 but for ISEQ.

I think it's useful to have the counter for ISEQs when we think about inlining ISEQs. It's also easier to use in production than TracePoint-based counters like Shopify/yjit-bench#163.

@matzbot matzbot requested a review from a team February 9, 2024 19:31
@k0kubun k0kubun marked this pull request as draft February 9, 2024 19:36
@k0kubun k0kubun marked this pull request as ready for review February 9, 2024 19:42
@maximecb
Copy link
Contributor

maximecb commented Feb 9, 2024

Good idea.

I realize this might be annoying to format, but could you also report the full path and line number for ISEQs? Would make it easy to find and go look at the ISEQs.

@k0kubun
Copy link
Member Author

k0kubun commented Feb 9, 2024

I realize this might be annoying to format, but could you also report the full path and line number for ISEQs?

In that case, this is the format I want to use 34f4c36, which is the same format as --dump=insns and ISeq#inspect:

Top-20 most frequent ISEQ calls (25.8% of ISEQ calls):
   325,515 ( 2.9%): context@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/activesupport-7.1.3/lib/active_support/isolated_execution_state.rb:57
   286,006 ( 2.5%): block in merge@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/activerecord-7.1.3/lib/active_record/relation/merger.rb:61
   280,556 ( 2.5%): state@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/activesupport-7.1.3/lib/active_support/isolated_execution_state.rb:69
   266,810 ( 2.4%): []@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/activesupport-7.1.3/lib/active_support/isolated_execution_state.rb:37
   233,238 ( 2.1%): each@<internal:array>:44
   200,838 ( 1.8%): klass@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/activerecord-7.1.3/lib/active_record/reflection.rb:411
   144,508 ( 1.3%): klass@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/activerecord-7.1.3/lib/active_record/associations/association.rb:151
   130,648 ( 1.2%): connection_specification_name@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/activerecord-7.1.3/lib/active_record/connection_handling.rb:260
   128,841 ( 1.1%): _read_attribute@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/activerecord-7.1.3/lib/active_record/attribute_methods/read.rb:50
    99,178 ( 0.9%): []@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/collection/map/non_concurrent_map_backend.rb:21
    97,477 ( 0.9%): empty@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/activerecord-7.1.3/lib/active_record/relation/where_clause.rb:95
    94,001 ( 0.8%): connected_to_stack@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/activerecord-7.1.3/lib/active_record/core.rb:189
    88,166 ( 0.8%): cast@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/activemodel-7.1.3/lib/active_model/type/value.rb:57
    87,438 ( 0.8%): fetch_value@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/activemodel-7.1.3/lib/active_model/attribute_set/builder.rb:41
    84,932 ( 0.8%): last@<internal:array>:200
    80,102 ( 0.7%): block in iterate_guarding_exceptions@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/activesupport-7.1.3/lib/active_support/notifications/fanout.rb:25
    78,586 ( 0.7%): iterate_guarding_exceptions@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/activesupport-7.1.3/lib/active_support/notifications/fanout.rb:22
    77,607 ( 0.7%): primary_key@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/activerecord-7.1.3/lib/active_record/attribute_methods/primary_key.rb:111
    70,848 ( 0.6%): to_sym@<internal:symbol>:23
    63,849 ( 0.6%): polymorphic?@/opt/rubies/after/lib/ruby/gems/3.4.0+0/gems/activerecord-7.1.3/lib/active_record/reflection.rb:671

This format allows you to naturally print Ruby blocks, which was not possible with the previous format.

I flipped the left and the right of the top-X tables since the label name is way too long to be on the left.

Copy link
Contributor

@maximecb maximecb left a comment

Choose a reason for hiding this comment

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

Looks good 👌

@k0kubun k0kubun enabled auto-merge (squash) February 9, 2024 22:09
@k0kubun k0kubun merged commit e7b0a01 into ruby:master Feb 9, 2024
96 of 97 checks passed
@k0kubun k0kubun deleted the yjit-ruby-call branch February 9, 2024 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants