-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Optimize libcxx-version for faster bootstrap startups #126467
Conversation
r? @onur-ozkan rustbot has assigned @onur-ozkan. Use |
Good idea with the |
That's already how it works rust/src/bootstrap/src/core/sanity.rs Lines 114 to 116 in bfa098e
|
I meant that it would be executed literally just before trying to download LLVM, not just when |
Are we sure these changes work without compatibility problems on old C++ compilers? The current code work on a fairly wide range of versions. |
The That being said, I don't think that we need to optimize this file at all, and instead we should just perform this check when it makes sense (i.e. when LLVM is being downloaded), and not on every run of bootstrap. |
I realized that caching the output is probably the better solution, I opened this PR because it was an easier change (at least for me), feel free to close this if it's not wanted :) |
We could refactor certain checks (not just the libcxx version) to be executed only once by using caching or stamp files, so they don't add overhead during active development. |
On my PC (64-bit Linux), the durations look like this:
So it seems like caching this specific check should be enough :) |
I just made some improvements on libcxx-version build in #126472 PR. I believe these changes alone should help without adding complexity to the sanity checks. |
Ofc, please correct me if I am wrong. |
This is a good optimization, but ultimately we want to avoid running the C++ compiler in every bootstrap invocation, which #126472 does. So I would prefer that solution instead. |
Ref: #126423
time (c++ src/tools/libcxx-version/main.cpp && ./a.out && rm ./a.out)
goes from ~180ms to ~50ms on my machine.I tried doing this at compile time with
#pragma message
, however I couldn't find a way to reliably parse the output across GCC and Clang. Here's how that would've looked like:cc @onur-ozkan as implementor in #125411