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

Refactor the interpreter loop to avoid performance degradation. #1777

Merged
merged 2 commits into from
Dec 30, 2024

Conversation

aardvark179
Copy link
Contributor

Extract function calls handling to a separate method to reduce the overall interpretLoop size.

While doing some benchmarking I noticed that the recent change to introduce super had caused a significant performance regression in the interpreter, which appears to be a result of the interpretLoop just getting too big for the JIT to do much with. This PR introduces paramterization to the benchmarks so that we test interpreted mode as well as compiled, and refactors the interpreter loop to extract the function call handling code.

This change appears to restore performance and get some small gains in the interpreter acrosss all benchmarks compared to a8696c7 (the commit immediately preceding the super implementation.

Merry Christmas everyone!

@aardvark179
Copy link
Contributor Author

aardvark179 commented Dec 24, 2024

For reference when run under the interpreter the V8 Richards benchmark looked like this before the super implementation:

Benchmark                    Mode  Cnt      Score    Error  Units
V8Benchmark.richards         avgt   20  12636.684 ± 23.466  us/op

After the change it looked like this:

Benchmark                    Mode  Cnt      Score     Error  Units
V8Benchmark.richards         avgt   20  60186.535 ± 986.924  us/op

And with the refactor it now looks like this:

Benchmark                    Mode  Cnt     Score    Error  Units
V8Benchmark.richards         avgt   20  9442.805 ± 25.955  us/op

These measurements were taken before I had properly parametrised the tests, hence they lack an (Interpreted) column in the output.

@aardvark179 aardvark179 force-pushed the aardvark179-interpreter-refactor2 branch from a5ef134 to 21043c1 Compare December 24, 2024 22:25
@rbri
Copy link
Collaborator

rbri commented Dec 24, 2024

Wow, super intresting, will try this with htmlunt

@gbrail
Copy link
Collaborator

gbrail commented Dec 26, 2024

I think that this is low-risk and fixes a regression and I think that we should adopt it for 1.8.0.

I wonder what other big hairy messes we have in the codebase that would benefit from a similar optimization? The "BodyCodegen" path doesn't get called as often but it's similarly awfully large!

@gbrail gbrail added this to the Release 1.8.0 milestone Dec 26, 2024
@gbrail
Copy link
Collaborator

gbrail commented Dec 30, 2024

Thanks -- this is very helpful!

@gbrail gbrail merged commit 98e9242 into mozilla:master Dec 30, 2024
3 checks passed
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