-
Notifications
You must be signed in to change notification settings - Fork 49
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
Change MSBuild to use the Clang backend #690
Comments
Last time I ran benchmarks, clang wasn't any better than MSVC on Windows (the clang-cl support works because I updated it to run this benchmark). It's also a really significant compatibility change, and there will certainly be users who want to keep building with MSVC. So I don't think we get to drop support entirely - it may only impact the python.org releases (possibly excluding the Store package, I'm not sure if clang support extends that far). Personally, I doubt it's worth the effort. But if someone wants to make the effort to show that it's both faster and remains binary compatible1, then go for it. Footnotes
|
@erozenfeld thank you for your attention. Sorry if I seem like I'm dunking on the MSVC compiler in the initial issue. If it seems overly negative, I'm sorry about that. Yes the link is #321 instead. But out of all the links, the only actionable one I think is python/cpython#121263. We've had a problem where Thank you for your time! |
@Fidget-Spinner Thank you for the clarification. I spent some time looking at python/cpython#121263. I found one compiler issue you are running into. Normally we compile functions in a bottom-up call graph order, i.e. callees before callers. That way we have more information for optimizations, including inlining. However, with multi-threaded compilation we schedule huge functions for earlier compilation in order to improve the overall multithreaded compilation time. The downside is that these huge functions don't always have information about callees, which results in worse code generation (and worse inlining decisions) for these huge functions. We are considering disabling that scheduling tweak for PGO (or perhaps for huge functions that are hot according to PGO info). In the meantime we have a switch that disables that: |
One more note: the compilation order scheduling tweak mentioned above affects not only |
I'll run a build with |
The I took the parent of python/cpython#121270, 93156880efd14ad7adc7d3512552b434f5543890, which still used To confirm this, I am going to run 2 more experiments over the weekend:
|
The results are in:
(All of this is with PGO, as is all of our benchmarking). So, it's clear that the flag helps (2% wins are hard to come by), and perhaps we should always use it for PGO builds (where the slower build times are already expected). But it's also clear that the macros (forcible inlining) are still helpful. Thanks again for all your help on this @erozenfeld. I'd be happy to help benchmark any ways to tweak the inlining heuristics that you think might be helpful. |
MSBuild has supported using clang backend for awhile now. https://learn.microsoft.com/en-us/cpp/build/clang-support-msbuild?view=msvc-170
MSVC has been somewhat unpredictable in comparison to the other compilers. We've had reports that it does not benefit from Python 3.11 1, of random slowdowns 2, of ceval.c being too big for MSVC to inline/optimize properly 3, and now, slowdowns that only hit it and no other platform 4.
We should seriously consider switching to another compiler, because it's starting to hinder our own productivity and performance goals on Windows.
The text was updated successfully, but these errors were encountered: