Repository navigation
Conversation
Add user32, shell32, ole32, oleaut32, crypt32, secur32 and ws2_32 to the existing delay-load list for rustup-init, so proxied cargo/rustc calls do not map them (and their dependencies) at start-up. They still load from System32 on first use.
rustup-init has no unit tests or benchmarks. Building its harnesses with --all-targets applies the binary's link arguments, so the delay-load list is linked without the code that imports user32, and /WX turns LNK4199 into a link error.
Member
|
Delay loading the DLLs is great but the fix in 958542d does not look right to me. It would be better to do something like gate it on |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reduce Windows proxy startup time by delay-loading system DLLs that the proxy path doesn't use.
This adds
user32,shell32,ole32,oleaut32,crypt32,secur32, andws2_32to the existing delay-load list inbuild.rs. The change is limited to linker configuration; no runtime code changes are needed.Motivation
Rustup proxies currently load several Windows system DLLs at process startup, even though the proxy path never uses them. Loading these DLLs and their transitive dependencies adds unnecessary startup overhead to every invocation of
cargo,rustc, and other proxied tools.Delay-loading these DLLs defers that cost until a code path actually needs them, such as
rustup checkor a download.Performance
Benchmarked on Windows 11 with an i9-14900K, using rustup 1.29.1 built from the release tag with
+crt-static(matching CI). Measurements used fresh binary copies, 40 interleaved passes, paired medians, and 95% confidence intervals.cargo +1.96.0 --versionThe change was faster in 35 of 40 passes.
The number of loaded images dropped from 25 to 14, eliminating startup loads of:
user32,gdi32,gdi32full,win32u,imm32,shell32,ole32,oleaut32,crypt32,iphlpapi, andmsvcp_win.For context, the proxy itself adds approximately 24.0 ms on Windows versus 3.1 ms on Linux. This change removes roughly one-sixth of the Windows proxy overhead.
Safety
rustup-init.rscallsSetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32)before the delay-loaded DLLs are needed, preserving the existing System32-only loading behavior.delayimp.libis already linked./WX, so an unused/DELAYLOADentry triggers LNK4199 and fails the build rather than silently becoming stale.Validation
Verified that the following produce the same output as before:
cargo --versionrustc -vVrustup showrustup which cargoAlso verified that
rustup checkcontinues to work over TLS.On current main (
5c8ff3f) the change also links with/WX. There the proxy goes from 27 to 14 loaded images, andcargo +1.96.0 --versiontakes 36.9 ms instead of 40.8 ms (paired median improvement 4.5 ms, 95% CI 3.7–6.0 ms, faster in 36 of 40 passes).Related work
proxy_mode(e.g. rustc wrapper) startup time? #2626 — Proxy startup performance