[incremental] Specialize encoding and decoding of Fingerprints #47243
[incremental] Specialize encoding and decoding of Fingerprints #47243bors merged 2 commits intorust-lang:masterfrom
Conversation
1f02e4f to
8b39266
Compare
michaelwoerister
left a comment
There was a problem hiding this comment.
Thanks a lot, @wesleywiser! This looks very good. Looking forward to seeing if it also has an impact on compile times.
I added some comments below: The encoding still has to be made platform-indepedent but that should be easy to implement.
src/librustc/ich/fingerprint.rs
Outdated
There was a problem hiding this comment.
Since we are emitting raw bytes here we can't rely on leb128 to take care integer endianess, so we have to do it ourselves. Fortunately that should be straightforward. Just write the following here:
let bytes: [u8; 16] = unsafe { mem::transmute((self.0.to_le(), self.1.to_le())) };and...
src/librustc/ich/fingerprint.rs
Outdated
There was a problem hiding this comment.
... the following here:
Ok(Fingerprint(u64::from_le(l), u64::from_le(r)))(If you get a method resolution error, you might have to use std::u64;)
8b39266 to
7c1c2be
Compare
|
@michaelwoerister fixed |
|
Thanks, @wesleywiser! Looks great now. @eddyb, do you know if Or are tuples always |
|
@michaelwoerister They're not |
|
Thanks for the quick reply, @eddyb! @wesleywiser, the following should avoid running into memory layout problems: ...
// When encoding
let bytes: [u8; 16] = unsafe { mem::transmute([self.0.to_le(), self.1.to_le()]) };
...
// When decoding (slices cannot be destructured unfortunately).
let fingerprint: [u64; 2] = unsafe { mem::transmute(bytes) };
Ok(Fingerprint(u64::from_le(fingerprint[0]), u64::from_le(fingerprint[1]))) |
You can do |
|
The |
This saves the storage space used by about 32 bits per `Fingerprint`.
On average, this reduces the size of the `/target/{mode}/incremental`
folder by roughly 5%.
Fixes rust-lang#45875
7c1c2be to
01c890e
Compare
|
Fixed |
|
Awesome, thank you! @bors r+ |
|
📌 Commit 01c890e has been approved by |
|
@bors p=15 Just moving everything which may improve performance up 😭 |
…elwoerister
[incremental] Specialize encoding and decoding of Fingerprints
This saves the storage space used by about 32 bits per `Fingerprint`.
On average, this reduces the size of the `/target/{mode}/incremental`
folder by roughly 5% [Full details here](https://gist.github.com/wesleywiser/264076314794fbd6a4c110d7c1adc43e).
Fixes #45875
r? @michaelwoerister
|
☀️ Test successful - status-appveyor, status-travis |
This saves the storage space used by about 32 bits per
Fingerprint.On average, this reduces the size of the
/target/{mode}/incrementalfolder by roughly 5% Full details here.
Fixes #45875
r? @michaelwoerister