-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Replace some u64 hashes with Hash64 #137095
Conversation
Could not assign reviewer from: |
r? @Noratrieb rustbot has assigned @Noratrieb. Use |
This comment has been minimized.
This comment has been minimized.
rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer |
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.
rust-analyzer can't depend on rustc_data_structures
since it doesn't compile on stable
This comment has been minimized.
This comment has been minimized.
time to put the wrapper in |
Actually I was thinking about creating |
Potentially silly alternative: byte arrays? |
In practice, all the little helper methods that permit numeric operations while keeping the containment of "do not encode me with leb128" are quite useful in the compiler. And these types get passed around a lot so I think it would be a silly maintenance issue to have multiple of them. I'll just figure out how to put these helper types in a crate that r-a can use. |
Sounds good. Also, @saethlin can you add this to the docs for Hash64? And likewise for Hash128. +/// A hashed u64 encoded with a stable size that is more compact than u64's ULEB128 encoding
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct Hash64 { That way it appears in hover-docs. |
Any variation on that sentence you want is fine, as long as it is a single one so that it consistently renders correctly. |
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
This comment has been minimized.
This comment has been minimized.
9b2f0af
to
7b99665
Compare
I factored this now so that the HashN types are in a new crate called Also, the |
Thanks, that's great! This should be fine. @bors r+ rollup |
Wait, I just remembered, there's a test to update, lemme check... @bors r- |
I believe rustc_hashes should be added to https://github.com/rust-lang/rust/blob/master/tests/run-make/rustc-crates-on-stable/rmake.rs |
This PR modifies cc @jieyouxu |
…shared with rust-analyzer
cd11624
to
4cf2186
Compare
Since you wanted to mark this for rollup, I'll wait until CI passes to re-add it to the queue |
@bors r+ |
…workingjubilee Replace some u64 hashes with Hash64 I introduced the Hash64 and Hash128 types in rust-lang#110083, essentially as a mechanism to prevent hashes from landing in our leb128 encoding paths. If you just have a u64 or u128 field in a struct then derive Encodable/Decodable, that number gets leb128 encoding. So if you need to store a hash or some other value which behaves very close to a hash, don't store it as a u64. This reverts part of rust-lang#117603, which turned an encoded Hash64 into a u64. Based on rust-lang#110083, I don't expect this to be perf-sensitive on its own, though I expect that it may help stabilize some of the small rmeta size fluctuations we currently see in perf reports.
…kingjubilee Rollup of 12 pull requests Successful merges: - rust-lang#136671 (Overhaul `rustc_middle::limits`) - rust-lang#136817 (Pattern Migration 2024: clean up and comment) - rust-lang#136844 (Use `const_error!` when possible) - rust-lang#136953 (rustc_target: import TargetMetadata) - rust-lang#137095 (Replace some u64 hashes with Hash64) - rust-lang#137100 (HIR analysis: Remove unnecessary abstraction over list of clauses) - rust-lang#137105 (Restrict DerefPure for Cow<T> impl to T = impl Clone, [impl Clone], str.) - rust-lang#137120 (Enable `relative-path-include-bytes-132203` rustdoc-ui test on Windows) - rust-lang#137125 (Re-add missing empty lines in the releases notes) - rust-lang#137140 (Fix const items not being allowed to be called `r#move` or `r#static`) - rust-lang#137145 (use add-core-stubs / minicore for a few more tests) - rust-lang#137149 (Remove SSE ABI from i586-pc-windows-msvc) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#137095 (Replace some u64 hashes with Hash64) - rust-lang#137100 (HIR analysis: Remove unnecessary abstraction over list of clauses) - rust-lang#137105 (Restrict DerefPure for Cow<T> impl to T = impl Clone, [impl Clone], str.) - rust-lang#137120 (Enable `relative-path-include-bytes-132203` rustdoc-ui test on Windows) - rust-lang#137125 (Re-add missing empty lines in the releases notes) - rust-lang#137145 (use add-core-stubs / minicore for a few more tests) - rust-lang#137149 (Remove SSE ABI from i586-pc-windows-msvc) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#137095 - saethlin:use-hash64-for-hashes, r=workingjubilee Replace some u64 hashes with Hash64 I introduced the Hash64 and Hash128 types in rust-lang#110083, essentially as a mechanism to prevent hashes from landing in our leb128 encoding paths. If you just have a u64 or u128 field in a struct then derive Encodable/Decodable, that number gets leb128 encoding. So if you need to store a hash or some other value which behaves very close to a hash, don't store it as a u64. This reverts part of rust-lang#117603, which turned an encoded Hash64 into a u64. Based on rust-lang#110083, I don't expect this to be perf-sensitive on its own, though I expect that it may help stabilize some of the small rmeta size fluctuations we currently see in perf reports.
I introduced the Hash64 and Hash128 types in #110083, essentially as a mechanism to prevent hashes from landing in our leb128 encoding paths. If you just have a u64 or u128 field in a struct then derive Encodable/Decodable, that number gets leb128 encoding. So if you need to store a hash or some other value which behaves very close to a hash, don't store it as a u64.
This reverts part of #117603, which turned an encoded Hash64 into a u64.
Based on #110083, I don't expect this to be perf-sensitive on its own, though I expect that it may help stabilize some of the small rmeta size fluctuations we currently see in perf reports.