-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add the unstable option to reduce the binary size of dynamic library… #118636
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @cjgillot (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
This comment has been minimized.
This comment has been minimized.
r? @m-ou-se |
Exciting results! This will have to be reviewed by the compiler team. I imagine they might want an MCP first. r? compiler |
☔ The latest upstream changes (presumably #118937) made this pull request unmergeable. Please resolve the merge conflicts. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ee932b5
to
750628c
Compare
This comment has been minimized.
This comment has been minimized.
Thanks for the PR and the MCP, @h1467792822! Looks very promising 🙂 |
@rustbot ready |
Add the unstable option to reduce the binary size of dynamic library… # Motivation The average length of symbol names in the rust standard library is about 100 bytes, while the average length of symbol names in the C++ standard library is about 65 bytes. In some embedded environments where dynamic library are widely used, rust dynamic library symbol name space hash become one of the key bottlenecks of application, Especially when the existing C/C++ module is reconstructed into the rust module. The unstable option `-Z symbol_mangling_version=hashed` is added to solve the bottleneck caused by too long dynamic library symbol names. ## Test data The following is a set of test data on the ubuntu 18.04 LTS environment. With this plug-in, the space saving rate of dynamic libraries can reach about 20%. The test object is the standard library of rust (built based on Xargo), tokio crate, and hyper crate. The contents of the Cargo.toml file in the construction project of the three dynamic libraries are as follows: ```txt # Cargo.toml [profile.release] panic = "abort" opt-leve="z" codegen-units=1 strip=true debug=true ``` The built dynamic library also removes the `.rustc` segments that are not needed at run time and then compares the size. The detailed data is as follows: 1. libstd.so > | symbol_mangling_version | size | saving rate | > | --- | --- | --- | > | legacy | 804896 || > | hashed | 608288 | 0.244 | > | v0 | 858144 || > | hashed | 608288 | 0.291 | 2. libhyper.so > | symbol_mangling_version(libhyper.so) | symbol_mangling_version(libstd.so) | size | saving rate | > | --- | --- | --- | --- | > | legacy | legacy | 866312 || > | hashed | legacy | 645128 |0.255| > | legacy | hashed | 854024 || > | hashed | hashed | 632840 |0.259|
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
…ed -Z unstable-options` to shorten symbol names by replacing them with a digest. Enrich test cases
@michaelwoerister Sorry, the code I submitted failed the test again. |
Thanks, @h1467792822 -- that seems like an appropriate solution. The cross-compiling issue is not related to what's being tested here, as far as I can tell. @bors r+ |
Add the unstable option to reduce the binary size of dynamic library… # Motivation The average length of symbol names in the rust standard library is about 100 bytes, while the average length of symbol names in the C++ standard library is about 65 bytes. In some embedded environments where dynamic library are widely used, rust dynamic library symbol name space hash become one of the key bottlenecks of application, Especially when the existing C/C++ module is reconstructed into the rust module. The unstable option `-Z symbol_mangling_version=hashed` is added to solve the bottleneck caused by too long dynamic library symbol names. ## Test data The following is a set of test data on the ubuntu 18.04 LTS environment. With this plug-in, the space saving rate of dynamic libraries can reach about 20%. The test object is the standard library of rust (built based on Xargo), tokio crate, and hyper crate. The contents of the Cargo.toml file in the construction project of the three dynamic libraries are as follows: ```txt # Cargo.toml [profile.release] panic = "abort" opt-leve="z" codegen-units=1 strip=true debug=true ``` The built dynamic library also removes the `.rustc` segments that are not needed at run time and then compares the size. The detailed data is as follows: 1. libstd.so > | symbol_mangling_version | size | saving rate | > | --- | --- | --- | > | legacy | 804896 || > | hashed | 608288 | 0.244 | > | v0 | 858144 || > | hashed | 608288 | 0.291 | 2. libhyper.so > | symbol_mangling_version(libhyper.so) | symbol_mangling_version(libstd.so) | size | saving rate | > | --- | --- | --- | --- | > | legacy | legacy | 866312 || > | hashed | legacy | 645128 |0.255| > | legacy | hashed | 854024 || > | hashed | hashed | 632840 |0.259|
💥 Test timed out |
@bors retry timeout (reoccurring) |
Add the unstable option to reduce the binary size of dynamic library… # Motivation The average length of symbol names in the rust standard library is about 100 bytes, while the average length of symbol names in the C++ standard library is about 65 bytes. In some embedded environments where dynamic library are widely used, rust dynamic library symbol name space hash become one of the key bottlenecks of application, Especially when the existing C/C++ module is reconstructed into the rust module. The unstable option `-Z symbol_mangling_version=hashed` is added to solve the bottleneck caused by too long dynamic library symbol names. ## Test data The following is a set of test data on the ubuntu 18.04 LTS environment. With this plug-in, the space saving rate of dynamic libraries can reach about 20%. The test object is the standard library of rust (built based on Xargo), tokio crate, and hyper crate. The contents of the Cargo.toml file in the construction project of the three dynamic libraries are as follows: ```txt # Cargo.toml [profile.release] panic = "abort" opt-leve="z" codegen-units=1 strip=true debug=true ``` The built dynamic library also removes the `.rustc` segments that are not needed at run time and then compares the size. The detailed data is as follows: 1. libstd.so > | symbol_mangling_version | size | saving rate | > | --- | --- | --- | > | legacy | 804896 || > | hashed | 608288 | 0.244 | > | v0 | 858144 || > | hashed | 608288 | 0.291 | 2. libhyper.so > | symbol_mangling_version(libhyper.so) | symbol_mangling_version(libstd.so) | size | saving rate | > | --- | --- | --- | --- | > | legacy | legacy | 866312 || > | hashed | legacy | 645128 |0.255| > | legacy | hashed | 854024 || > | hashed | hashed | 632840 |0.259|
☀️ Test successful - checks-actions |
Finished benchmarking commit (04521fd): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 660.976s -> 660.806s (-0.03%) |
Motivation
The average length of symbol names in the rust standard library is about 100 bytes, while the average length of symbol names in the C++ standard library is about 65 bytes. In some embedded environments where dynamic library are widely used, rust dynamic library symbol name space hash become one of the key bottlenecks of application, Especially when the existing C/C++ module is reconstructed into the rust module.
The unstable option
-Z symbol_mangling_version=hashed
is added to solve the bottleneck caused by too long dynamic library symbol names.Test data
The following is a set of test data on the ubuntu 18.04 LTS environment. With this plug-in, the space saving rate of dynamic libraries can reach about 20%.
The test object is the standard library of rust (built based on Xargo), tokio crate, and hyper crate.
The contents of the Cargo.toml file in the construction project of the three dynamic libraries are as follows:
The built dynamic library also removes the
.rustc
segments that are not needed at run time and then compares the size. The detailed data is as follows: