-
Notifications
You must be signed in to change notification settings - Fork 888
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
Rustup uses backtrace regardless of RUST_BACKTRACE #591
Comments
I suspect this is due to the use of the |
@Diggsey thanks regardless of I am not so lucky to hear about that. Any way to disable it? I've set |
@pravic Does this only happen when rustup ends with an error or does it also happen when rustup exits successfully? (I don't know why any backtrace code would be running on success) I'd like to know more about what it means to 'scan your HDD'. Why is this a problem for you? |
@brson There are no errors in regular The problem is in unnesessary HDD access which is quiet noisy and slowly. And thats despite of incorrect behavior with RUST_BACKTRACE ignoring. |
Here's the strace output of
That doesn't look unexpected, though I'm not sure what the So the same strace on
Suddenly some code is very interested in terminfo, but still nothing that looks particularly out of the ordinary. But I guess since you mentioned |
@pravic when you mention that @brson I think that error-chain captures a stack trace when any error happens, right? That means that a backtrace would be captured for an error which is later ignored I believe? It may be worth optimizing some stuff in backtrace-rs for this use case if it's causing perf problems. |
Yes, backtraces are generated for all errors regardless of whether they are displayed to the user. |
Looks like this can be an expensive operation [1] so we shouldn't be calling it... once per symbol and stack trace! [1]: rust-lang/rustup#591
Ok, I've pushed a commit to backtrace-rs which should greatly reduce the number of times |
I'm having some issues with my windows build at the moment, but when I've resolved them I'll post a testing build. |
@pravic Here's a build that contains @alexcrichton's fixes. Maybe you can test it and see if it performs better for you: https://s3-us-west-1.amazonaws.com/static-rust-lang-org/rustup/temp-testing/rustup-init.exe |
Just checked (rustup 0.3.0): Well, I checked new build. Behavior the same, since all symbols were loaded on first SymInitialize call, because it enumerates all process modules and tries to load (or download) pdb file for each. But yes, backtrace calls SymInitialize many times before patch:
The only solution I found, it is disable "dbghelp" feature of backtrace completely. I definitely do not need a flying error chains with linked backtraces, RUST_BACKTRACE is enough for me when it needed. |
I wonder why running |
Guess, thats how windows symbol handler works.
|
Hm, @pravic if the simple Do you see the same behavior with |
|
Thanks @pravic. @alexcrichton can you think of any reason rustc and rustup would differ in this behavior? Apparently |
The standard library doesn't hit backtrace logic until a panic happens, which |
For example when I run
Presumably a backtrace is getting generated each time that happens? |
Oh duh. There is indeed some code that runs even before argument parsing. Argh, I wish I knew why this disk access is so horrible on @pravic's system but doesn't seem to be on others. It really isn't that important to carry the backtraces around most of the time so maybe it is worth just converting error-chain to obey |
Next step is to make the modification to error-chain then upgrade it in rustup. The rustup error code tries to show backtraces on |
Update to error-chain 0.5.0 to allow optional backtrace. #591
A fix for this was merged. |
This commit updates the behavior of backtraces on Windows to execute `SymInitializeW` globally once-per-process and ignore the return value as to whether it succeeded or not. This undoes previous work in this crate to specifically check the return value, and this is a behavior update for the standard library when this goes into the standard library. The `SymInitializeW` function is required to be called on MSVC before any backtraces can be captured or before any addresses can be symbolized. This function is quite slow. It can only be called once-per-process and there's a corresponding `SymCleanup` to undo the work of `SymInitializeW`. The behavior of what to do with `SymInitializeW` has changed a lot over time in this crate. The very first implementation for Windows paired with `SymCleanup`. Then reports of slowness at rust-lang/rustup#591 led to ac8c6d2 where `SymCleanup` was removed. This led to #165 where because the standard library still checked `SymInitializeW`'s return value and called `SymCleanup` generating a backtrace with this crate would break `RUST_BACKTRACE=1`. Finally (and expectedly) the performance report has come back as #229 for this crate. I'm proposing that the final nail is put in this coffin at this point where this crate will ignore the return value of `SymInitializeW`, initializing symbols once per process globally. This update will go into the standard library and get updated on the stable channel eventually, meaning both libstd and this crate will be able to work with one another and only initialize the process's symbols once globally. This does mean that there will be a period of "breakage" where we will continue to make `RUST_BACKTRACE=1` not useful if this crate is used on MSVC, but that's sort of the extension of the status quo as of a month or so ago. This will eventually be fixed once the stable channel of Rust is updated.
I noticed that
rustup update
scans my HDD every time it been called.I found that it always initializes a symbol helper (dbghelp!SymInitialize) at begin.
Setting
RUST_BACKTRACE=0
or removingRUST_BACKTRACE
does not help.Any explanation/recomendations about it? I tested cargo also, it does not load .pdb every time like rustup does.
The text was updated successfully, but these errors were encountered: