-
Notifications
You must be signed in to change notification settings - Fork 8
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
On PyPy (and maybe future CPython), you probably want to make sure the function is JITed #33
Comments
The worry is that the JIT compilation will ... "over-optimize" the code. See e.g. this explanation of why this Rust benchmark framework requires the use of the I will do some investigation and report back. |
This is definitely going to be a problem (and likely for |
Further discussion with PyPy authors suggests that over-optimization of code (where you end up benchmarking code that won't match real world code) is not really solvable by the framework. It will likely require changes to the framework to make it easier for benchmark authors, documentation change, and benchmarks to be written in a particular way. If CPython gets a JIT, this will likely become an even bigger issue. I am therefore going to do some more research and then make suggestions that will presumably require pytest-benchmark changes too. Will report back. |
Thanks a lot for the investigation. I totally agree with your Point of View, and it's already quite painful in compiled languages. Definitely, this optimization topic will be a big problem. One way to "solve" it would be to ignore and disable the JIT, but this won't match real-world data. You also mentioned warmup to make the JIT optimize the function; this might be hard. We ran some experiments with V8 but didn't find a definitive way to ensure the optimization of the whole execution path. Is there anything to force optimization with Pypy? I'm not aware if such a thing is also planned with CPython. |
With PyPy you run the function ~3000 times and that triggers JIT compilation. |
PyPy uses a JIT, so the initial run of a function may be misleading: after some number of runs the JIT kicks in, and then it will run much faster. CPython is working on a JIT too, so this may be relevant to future CPython releases as well (possibly even 3.13).
The code would likely look like:
The text was updated successfully, but these errors were encountered: