Uh oh!
There was an error while loading. Please reload this page.
Compress most of spans to 32 bits - #44646
Conversation
|
There was a problem hiding this comment.
Span is not Send/Sync if it uses thread-local interner and profile queries are sent to other threads, so I had to temporary remove spans from them.
I'll restore this back later, queries will have to use SpanData instead of Span (I hoped to keep it private, but it looks like there's no better choice :( ).
There was a problem hiding this comment.
If encoding/decoding with 2-bit tag looks too error-prone/unmaintainable (or turns out to be too slow), then I can redo this with 1-bit tag instead, it will reduce the persentage of inlined spans from 82.68% to 80.01% (on rustc/libstd data).
There was a problem hiding this comment.
@michaelwoerister
I'm not sure if Span can derive Hash or not (for incremental, etc).
Is hashing the 32-bit "index" enough for interned spans, or actual data must be hashed?
There was a problem hiding this comment.
Incremental uses HashStable anyway.
There was a problem hiding this comment.
Yes, as @arielb1 says. We keep hashing for incr. comp. separate because often it's a lot expensive than what we need for a regular hash table and it often requires additional contextual information. So you don't have to worry about it.
You might want to provide a specialized implementation that hashes just one 32 bit value instead for bytes though (unless we do that anyway). But probably not worth the trouble.
Why are you using a |
petrochenkov
commented
Sep 17, 2017
Yes.
Are reads from |
Mark-Simulacrum
commented
Sep 17, 2017
We can run this through perf.rlo's benchmarks when ready, just run a try build and ping me on completion. |
arielb1
commented
Sep 17, 2017
That's right - otherwise packed structs would be quite useless. And #27060 (which I'm working on fixing right now) only means that some code that should be |
bors
commented
Sep 17, 2017
☔ The latest upstream changes (presumably #44654) made this pull request unmergeable. Please resolve the merge conflicts. |
michaelwoerister
commented
Sep 18, 2017
This looks awesome, @petrochenkov! |
a45b07a to
f069c88Comparepetrochenkov
commented
Sep 18, 2017
Updated. |
bors
commented
Sep 18, 2017
Compress most of spans to 32 bits As described in https://internals.rust-lang.org/t/rfc-compiler-refactoring-spans/1357/28Closes#15594 r? @michaelwoerister
bors
commented
Sep 19, 2017
☀️ Test successful - status-travis |
michaelwoerister
commented
Sep 19, 2017
@arielb1, I tried typing the merge commit hashes into perf.rlo compare but that didn't seem to work for me. Did you have a different method for performance comparison in mind? |
petrochenkov
commented
Sep 19, 2017
ping @Mark-Simulacrum |
llogiq
commented
Sep 19, 2017
I notice that the interner uses a default |
petrochenkov
commented
Sep 20, 2017
I looked through the performance data a bit. What we try to optimize is memory, i.e. max-rss. On the other side there are more regressions in speed. I don't know what exactly the tests measure (e.g. how |
michaelwoerister
commented
Sep 20, 2017
Many of the tests showing regressions are ones with incremental compilation activated. Incremental compilation has to expand all spans to Great find, @llogiq! This should definitely use |
petrochenkov
commented
Sep 20, 2017
@bors try |
bors
commented
Sep 20, 2017
🔒 Merge conflict |
e723bf6 to
cb1158fComparepetrochenkov
commented
Sep 20, 2017
@bors try |
bors
commented
Sep 20, 2017
Compress most of spans to 32 bits As described in https://internals.rust-lang.org/t/rfc-compiler-refactoring-spans/1357/28Closes#15594 r? @michaelwoerister
petrochenkov
commented
Sep 22, 2017
@michaelwoerister
"32-bit span, 1-bit tag" still seems to be better |
michaelwoerister
commented
Sep 22, 2017
Alright, thanks for checking! 32 bits with 1 bit tag seems to be a good choice indeed. Maybe If you make the interner use an |
| // option. This file may not be copied, modified, or distributed | ||
| // except according to those terms. | ||
| // Spans are encoded using 2-bit tag and 4 different encoding formats for each tag. |
74f4271 to
52251cdComparepetrochenkov
commented
Sep 22, 2017
@michaelwoerister |
michaelwoerister
commented
Sep 25, 2017
@bors r+ Thanks, @petrochenkov! Looking forward to seeing the results |
bors
commented
Sep 25, 2017
📌 Commit 52251cd has been approved by |
bors
commented
Sep 25, 2017
Compress most of spans to 32 bits As described in https://internals.rust-lang.org/t/rfc-compiler-refactoring-spans/1357/28Closes#15594 r? @michaelwoerister
bors
commented
Sep 25, 2017
☀️ Test successful - status-appveyor, status-travis |
alexcrichton
commented
Sep 27, 2017
Looks like this may have improved the memory of the tuple-stress benchmark by 5%! |
Optimize some span operations Do not decode span data twice/thrice/etc unnecessarily. Applied to stable hashing and all methods in `impl Span`. Follow up to rust-lang#44646 r? @michaelwoerister
Due the limitation that #[derive(...)] on #[repr(packed)] structs does not guarantee proper alignment of the compiler-generated impls is not guaranteed (rust-lang#39696), the change in rust-lang#44646 to compress Spans results in the compiler generating code with unaligned access. Until rust-lang#39696 has been fixed, the issue can be worked around by not using the packed attribute on sparc64 and sparcv9 on the Span struct. Fixes: rust-lang#45509
As described in https://internals.rust-lang.org/t/rfc-compiler-refactoring-spans/1357/28
Closes#15594
r? @michaelwoerister