-
Notifications
You must be signed in to change notification settings - Fork 112
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
Eliminate redundant register swapping in JIT #384
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ChinYikMing
reviewed
Mar 13, 2024
jserv
reviewed
Mar 13, 2024
jserv
reviewed
Mar 13, 2024
jserv
reviewed
Mar 13, 2024
qwe661234
reviewed
Mar 13, 2024
qwe661234
approved these changes
Mar 16, 2024
vacantron
commented
Mar 16, 2024
jserv
reviewed
Mar 16, 2024
jserv
requested changes
Mar 17, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Append "Close #330" at the end of git commit message because the work is considered as completed after RA is refined.
In the current register allocation of JIT, we save the host registers before using to keep the consistency of the content between the vm and the host register, even it had not been changed by any other operation after loaded from the stack. This generates lots of redundant `store` related instructions on the host and reduces the performance of vm. In this patch, we introduce the `dirty` flag to record the status of the host register. Once the content of the host register is changed by an operation, the flag is set to 1. The register swapping will only be invoked when the register is dirty in next allocation. The performance improvement after this patch is shown below: * x86-64 | Metric | Original | Improved | SpeedUp | |-----------+----------+----------+---------| | dhrystone | 0.623 s | 0.463 s | +25.6% | | miniz | 3.437 s | 2.837 s | +17.5% | | primes | 4.435 s | 3.205 s | +27.7% | | sha512 | 3.212 s | 3.024 s | +5.9% | | aes | 1.708 s | 1.545 s | +9.5% | | qsort | 5.236 s | 5.219 s | +0.3% | * aarch64 | Metric | Original | Improved | SpeedUp | |-----------+----------+----------+---------| | dhrystone | 1.003 s | 0.897 s | +10.6% | | miniz | 4.312 s | 4.107 s | +4.8% | | primes | 9.605 s | 8.879 s | +7.6% | | sha512 | 5.902 s | 5.796 s | +1.8% | | aes | 2.932 s | 2.891 s | +1.4% | | qsort | 6.123 s | 5.988 s | +2.2% | Close sysprog21#330
Thank @vacantron for contributing! |
vestata
pushed a commit
to vestata/rv32emu
that referenced
this pull request
Jan 24, 2025
Eliminate redundant register swapping in JIT
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the current register allocation of JIT, we save the host registers before using to keep the consistency of the content between the vm and the host register, even it had not been changed by any other operation after loaded from the stack. This generates lots of redundant
store
related instructions on the host and reduces the performance of vm.In this patch, we introduce the
dirty
flag to record the status of the host register. Once the content of the host register is changed by an operation, the flag is set to 1. The register swapping will only be invoked when the register is dirty in next allocation.The performance improvement after this patch is shown below: