-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Encode hashes as bytes, not varint #110083
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 8627fe1a80c6f8cabc961d8ca7df3d05a61e956a with merge 6de33b85fc2e7dfa93da079f1e2e5b09b9fd618b... |
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
I don't think hash should be defined as bytes -- doing so reduces alignment and can be detrimental (especially on platforms that don't have efficient misaligned memory access). Also on 32-bit platforms, they now have to be passed via memory. If this is only about encoding then a new type with custom |
Finished benchmarking commit (6de33b85fc2e7dfa93da079f1e2e5b09b9fd618b): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
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. |
Cachegrind diff for the one benchmark with significant improvement says:
Which is not what I would have predicted. Interesting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which is not what I would have predicted. Interesting.
Maybe the hashes for type-ids? u*::MAX
constants?
8627fe1
to
5118a86
Compare
I've touched a lot more code now... |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 5118a860452ba5c8d48159ddaa18febcae879b37 with merge 4dc92c4e8ab0d1196d7c7b485a13ce4cbe848b4b... |
This comment has been minimized.
This comment has been minimized.
caec88f
to
16ada86
Compare
Once more, with feeling |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 16ada86621692739ee72861fb9c15043f1d27768 with merge e89b3eb207a1843d10eccc438536aeca22752ecf... |
☀️ Try build successful - checks-actions |
☔ The latest upstream changes (presumably #110367) made this pull request unmergeable. Please resolve the merge conflicts. |
124aaec
to
50d202f
Compare
This comment has been minimized.
This comment has been minimized.
50d202f
to
6df4b53
Compare
Rebased over #110343 to simplify the distributions in the PR description. |
6df4b53
to
a04c09a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would a few inlines be helpful?
r=me either way
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (b3f1379): comparison URL. Overall result: ❌✅ regressions and improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
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. |
In a few places, we store hashes as
u64
oru128
and then applyderive(Decodable, Encodable)
to the enclosing struct/enum. It is more efficient to encode hashes directly than try to apply some varint encoding. This PR adds two new typesHash64
andHash128
which are produced byStableHasher
and replace every use of storing au64
oru128
that represents a hash.Distribution of the byte lengths of leb128 encodings, from
x build --stage 2
withincremental = true
Before:
After:
The remaining 9 or 10 and 18 or 19 are
u64
andu128
respectively that have the high bits set. As far as I can tell these are coming primarily fromSwitchTargets
.