Skip to content

YJIT: Skip padding jumps to side exits on Arm #6790

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

Merged
merged 1 commit into from
Nov 22, 2022

Conversation

k0kubun
Copy link
Member

@k0kubun k0kubun commented Nov 22, 2022

This PR revisits the idea I shared at #6757 (comment).

Jumps to side exits are non-patchable, so we don't need to generate nops for these cases.

Benchmark

A release build on Arm becomes 1.02x faster.

before: ruby 3.2.0dev (2022-11-21T18:52:44Z master cf05c202ce) +YJIT [arm64-darwin22]
after: ruby 3.2.0dev (2022-11-22T19:09:31Z yjit-side-exit-ptr e513fe1ad3) +YJIT [arm64-darwin22]

----------  -----------  ----------  ----------  ----------  ------------  -------------
bench       before (ms)  stddev (%)  after (ms)  stddev (%)  before/after  after 1st itr
railsbench  710.1        2.4         693.6       1.1         1.02          0.99
----------  -----------  ----------  ----------  ----------  ------------  -------------
$ ./run_benchmarks.rb railsbench -e "before::/opt/rubies/yjit-release-before-$arch/bin/ruby --yjit" -e "after::/opt/rubies/yjit-release-after-$arch/bin/ruby --yjit"
Running benchmark "railsbench" (1/1)
/opt/rubies/yjit-release-before-arm64/bin/ruby --yjit -I ./harness benchmarks/railsbench/benchmark.rb
ruby 3.2.0dev (2022-11-21T18:52:44Z master cf05c202ce) +YJIT [arm64-darwin22]
Command: bundle check 2> /dev/null || bundle install
The Gemfile's dependencies are satisfied
Command: bin/rails db:migrate db:seed
Deleted all 100 posts
Creating 100 posts....................................................................................................
itr #1: 857ms
itr #2: 730ms
itr #3: 704ms
itr #4: 739ms
itr #5: 723ms
itr #6: 715ms
itr #7: 719ms
itr #8: 699ms
itr #9: 680ms
itr #10: 719ms
itr #11: 698ms
itr #12: 699ms
itr #13: 706ms
itr #14: 718ms
itr #15: 694ms
itr #16: 727ms
itr #17: 705ms
itr #18: 697ms
itr #19: 686ms
itr #20: 715ms
itr #21: 740ms
itr #22: 703ms
itr #23: 694ms
itr #24: 731ms
itr #25: 696ms
Average of last 10, non-warmup iters: 710ms
Running benchmark "railsbench" (1/1)
/opt/rubies/yjit-release-after-arm64/bin/ruby --yjit -I ./harness benchmarks/railsbench/benchmark.rb
ruby 3.2.0dev (2022-11-22T19:09:31Z yjit-side-exit-ptr e513fe1ad3) +YJIT [arm64-darwin22]
Command: bundle check 2> /dev/null || bundle install
The Gemfile's dependencies are satisfied
Command: bin/rails db:migrate db:seed
Deleted all 100 posts
Creating 100 posts....................................................................................................
itr #1: 864ms
itr #2: 706ms
itr #3: 688ms
itr #4: 696ms
itr #5: 690ms
itr #6: 687ms
itr #7: 710ms
itr #8: 706ms
itr #9: 687ms
itr #10: 686ms
itr #11: 685ms
itr #12: 694ms
itr #13: 686ms
itr #14: 685ms
itr #15: 692ms
itr #16: 705ms
itr #17: 685ms
itr #18: 691ms
itr #19: 688ms
itr #20: 687ms
itr #21: 689ms
itr #22: 705ms
itr #23: 704ms
itr #24: 691ms
itr #25: 686ms
Average of last 10, non-warmup iters: 693ms
Total time spent benchmarking: 41s

before: ruby 3.2.0dev (2022-11-21T18:52:44Z master cf05c202ce) +YJIT [arm64-darwin22]
after: ruby 3.2.0dev (2022-11-22T19:09:31Z yjit-side-exit-ptr e513fe1ad3) +YJIT [arm64-darwin22]
end_time: 2022-11-22 11:12:18 PST (-0800)

----------  -----------  ----------  ----------  ----------  ------------  -------------
bench       before (ms)  stddev (%)  after (ms)  stddev (%)  before/after  after 1st itr
railsbench  710.1        2.4         693.6       1.1         1.02          0.99
----------  -----------  ----------  ----------  ----------  ------------  -------------
Legend:
- before/after: ratio of before/after time. Higher is better for after. Above 1 represents a speedup.
- after 1st itr: ratio of before/after time for the first benchmarking iteration.

Code Size

inline_code_size is decreased by 8% with a release build on Arm.

Before

inline_code_size:         4795980
outlined_code_size:       4794088
freed_code_size:                0
code_region_size:         9601024

After

inline_code_size:         4415324
outlined_code_size:       4411532
freed_code_size:                0
code_region_size:         8830976

@k0kubun k0kubun changed the title YJIT: Skip padding a jump to side exits YJIT: Skip padding jumps to side exits Nov 22, 2022
Co-authored-by: Maxime Chevalier-Boisvert <[email protected]>
Co-authored-by: Alan Wu <[email protected]>
@k0kubun k0kubun changed the title YJIT: Skip padding jumps to side exits YJIT: Skip padding jumps to side exits on Arm Nov 22, 2022
@k0kubun k0kubun marked this pull request as ready for review November 22, 2022 19:36
@matzbot matzbot requested a review from a team November 22, 2022 19:36
@maximecb maximecb merged commit 63f4a7a into ruby:master Nov 22, 2022
@maximecb maximecb deleted the yjit-side-exit-ptr branch November 22, 2022 20:57
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.

2 participants