-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Figure out how to make symbolisation code smaller #139209
Comments
For the sorting, if it’s not performance critical then you can shrink the code to a few hundred bytes per monomorphization by using very simple textbook algorithms instead of the smart modern hybrid methods (see https://github.com/Voultapher/tiny-sort-rs for example). |
|
As far as I can tell,
I'm genuinely curious: Do you know if anyone uses symbolisation in the hot path? It just seems unlikely to me that anyone would care about performance, especially in cases where the program has encountered a bug anyway.
That's good to know, we'd need to keep that in mind. |
No, std debuginfo is absent in release mode because cargo passes
anyhow shows backtraces on regular errors when |
Ah, fair enough...
Oh yeah, regressing that wouldn't be great... |
(Edit: oops, typed too slow and didn’t see the earlier comment by @bjorn3 saying the same more succinctly) Capturing and formatting backtraces in-process can be performance critical when error values include a backtrace and errors occur and are (for example) logged with non-trivial frequency. See dtolnay/anyhow#380 for a complaint about this in the wild. As for |
Tangential point: even if we can’t rip out the symbolication code entirely in favor of |
Rust binaries are notoriously large. For instance, a simple, release-mode "Hello, world!" binary has a size of over 400 kB on my machine (ARM macOS). Much of this size (probably more than half) comes from the symbolisation that
std
performs when printing backtraces, as that pulls in a DWARF parser, an ELF/Mach-O parser, four instantiations ofsort
and some other things in order to support printing line numbers and file names. Annoyingly, this code is almost completely redundant when a binary is compiled with the release profile, as that profile disables the generation of the very DWARF debug info that all that code aims to use. Thus, when compiling with-C debuginfo=none
, all this code could be replaced by a simpledladdr
call without any loss of functionality.Unfortunately,
std
being pre-compiled makes fixing this is rather difficult since we can't just add a feature flag tostd
and turn that on and off depending on compiler flags. My idea here would be to copy the strategy used to implement-C panic
and make-C debuginfo
select between two separate crates: one that calls back intostd
to employ thebacktrace-rs
logic and one that usesdladdr
or a similar platform function. I'm not sure that's feasible, however.This issue exists to coordinate work on reducing the size of
backtrace-rs
(there are some obvious some fixes like using dynamic dispatch to reduce the number ofsort
instantiations) and to discuss strategies for reducing the binary size further.The text was updated successfully, but these errors were encountered: