-
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
Use a more efficient encoding for opaque data in RBML. #30565
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
0245e4e
to
d2ce797
Compare
Which it by the way shouldn't do for 1-byte and floating point numbers... I'll change that in a separate PR some time. |
cc @alexcrichton @brson who might be interested in things concerning the binary size of our libraries. |
@arielb1 Worked on metadata, and I remember something about switching to a fixed-sized integer model (for decoding speed? not sure). |
@eddyb I did some non-rigorous performance comparisons, compiling libsyntax a few times with and without the changes in this PR. I found no observable difference between the two. That being said, once the support for an alternate encoding is in place, it would be easy to change how numbers and other primitive types are emitted and we could take a look if fixed size integer would make things faster (although I doubt that it makes much of a difference for overall compilation time). |
I don't see any problems with the idea itself. |
We probably don't need 2 separate vuint encoding schemes (rbml's |
Incidentally, the primary worry is not the cost of writing metadata but that of reading it - which is already 2% of compilation time with the old code according to some old measurements I have made. For that, |
☔ The latest upstream changes (presumably #30582) made this pull request unmergeable. Please resolve the merge conflicts. |
In principle I agree. RBML vuint can only handle unsigned values though and I don't know if we want to break away from EBML's prescribed encodings for tags and sizes. |
Here are some timings from compiling librustc_driver:
I don't see much of a difference between any of those. |
d2ce797
to
fa2a741
Compare
... rebased |
Looks good. |
@bors r+ |
📌 Commit fa2a741 has been approved by |
⌛ Testing commit fa2a741 with merge 23a80cc... |
👀 Test was successful, but fast-forwarding failed: 422 Reference already exists |
…brson This PR changes the `emit_opaque` and `read_opaque` methods in the RBML library to use a space-efficient binary encoder that does not emit any tags and uses the LEB128 variable-length integer format for all numbers it emits. The space savings are nice, albeit a bit underwhelming, especially for dynamic libraries where metadata is already compressed. | RLIBs | NEW | OLD | |--------------|--------|-----------| |libstd | 8.8 MB | 10.5 MB | |libcore |15.6 MB | 19.7 MB | |libcollections| 3.7 MB | 4.8 MB | |librustc |34.0 MB | 37.8 MB | |libsyntax |28.3 MB | 32.1 MB | | SOs | NEW | OLD | |---------------|-----------|--------| | libstd | 4.8 MB | 5.1 MB | | librustc | 8.6 MB | 9.2 MB | | libsyntax | 7.8 MB | 8.4 MB | At least this should make up for the size increase caused recently by also storing MIR in crate metadata. Can this be a breaking change for anyone? cc @rust-lang/compiler
This PR changes the
emit_opaque
andread_opaque
methods in the RBML library to use a space-efficient binary encoder that does not emit any tags and uses the LEB128 variable-length integer format for all numbers it emits.The space savings are nice, albeit a bit underwhelming, especially for dynamic libraries where metadata is already compressed.
At least this should make up for the size increase caused recently by also storing MIR in crate metadata.
Can this be a breaking change for anyone?
cc @rust-lang/compiler