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

mypyc + bidict #1045

Open
jab opened this issue Jan 17, 2024 · 1 comment
Open

mypyc + bidict #1045

jab opened this issue Jan 17, 2024 · 1 comment

Comments

@jab
Copy link

jab commented Jan 17, 2024

I just noticed that https://github.com/python/mypy/tree/master/mypyc#development-status-and-roadmap says:

Let us know if you maintain another Python tool or library and are interested in working with us on this!

I recently experimented with using mypyc to compile a hot loop that I extracted from the bidict code (please click that link to see the changes, which are straightforward and should be easy to follow), benchmarked in CI (under cachegrind as per Itamar), and got some unexpected results:

Performance has regressed:
test_bi_contains_key_present[99] (baseline) - Field 'min' has failed PercentageRegressionCheck: 10.754302527 > 10.000000000
test_bi_contains_key_present[999] (baseline) - Field 'min' has failed PercentageRegressionCheck: 52.402354267 > 10.000000000

I expected that running the mypyc-compiled version of this hot loop would be much faster than running the interpreted version for affected benchmarks, and certainly not significantly slower for any benchmarks. But I did not see any speedup, and many benchmarks ran slower (e.g. the two quoted above got more than 10% slower).

Not sure if this is due to a gap in mypyc, or if there's just not much mypyc could ever do to make this code run faster. I'd love to look at this with a mypyc expert. Hopefully it's still possible to ship a much faster release of bidict thanks to mypyc, and unlock potential for other projects in the process.

Thanks for maintaining mypyc!

@jab
Copy link
Author

jab commented Jan 21, 2024

Is running a benchmark under (warmed up) PyPy and comparing to interpreted CPython predictive (to a crude approximation) of whether mypyc would enable a significant speedup?

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

No branches or pull requests

1 participant