rust/src
bors 936ce3dab7 Auto merge of #92103 - Kobzol:stable-hash-skip-zero-bytes, r=the8472
Do not hash leading zero bytes of i64 numbers in Sip128 hasher

I was poking into the stable hasher, trying to improve its performance by compressing the number of hashed bytes. First I was experimenting with LEB128, but it was painful to implement because of the many assumptions that the SipHasher makes, so I tried something simpler - just ignoring leading zero bytes. For example, if an 8-byte integer can fit into a 4-byte integer, I will just hash the four bytes.

I wonder if this could produce any hashing ambiguity. Originally I thought so, but then I struggled to find any counter-example where this could cause different values to have the same hash. I'd be glad for any examples that could be broken by this (there are some ways of mitigating it if that would be the case). It could happen if you had e.g. 2x `u8` vs 1x `u16` hashed after one another in two different runs, but that can also happen now, without this "trick". And with collections, it should be fine, because the length is included in their hash.

I gathered some statistics for common values used in the `clap` benchmark. I observed that especially `i64` often had very low values, so I started with that type, let's see what perf does on CI.

There are some tradeoffs that we can try:
1) What types to use this optimization for? `u64`, `u32`, `u16`? Locally it was a slight loss for `u64`, I noticed that its values are often quite large.
2) What byte sizes to check? E.g. we can only distinguish between `u64`/`u32` or `u64`/`u8` instead of `u64`/`u32`/`u16`/`u8` to reduce branching (with `i64` it seemed to be better to go all the way down to `u8` locally though).

(The macro was introduced because I expect that I will be trying out this "trick" for different types).

Can you please schedule a perf. run? Thanks.

r? `@the8472`
2022-01-05 09:27:18 +00:00
..
bootstrap Do not use deprecated -Zsymbol-mangling-version in bootstrap 2022-01-04 12:06:46 -05:00
build_helper Migrate to 2021 2021-09-20 22:21:42 -04:00
ci Rollup merge of #92440 - GuillaumeGomez:fix-mobile-toggles, r=jsha 2021-12-31 23:14:49 +01:00
doc Update books 2022-01-03 19:45:10 -08:00
etc Implement @snapshot check for htmldocck 2021-12-01 15:12:10 -08:00
librustdoc Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwU 2022-01-04 21:23:06 +01:00
llvm-project@6b3dbcc81a Backport LLVM changes to disable deferred inlining 2021-12-19 23:49:03 +02:00
rustdoc-json-types Moved format-version constant to rustdoc-json-types 2021-10-15 12:27:42 +03:00
test Auto merge of #92103 - Kobzol:stable-hash-skip-zero-bytes, r=the8472 2022-01-05 09:27:18 +00:00
tools Auto merge of #92567 - ehuss:update-cargo, r=ehuss 2022-01-05 03:03:17 +00:00
README.md
stage0.json Bump bootstrap compiler 2021-11-30 10:44:21 -05:00
version Bump to 1.59 2021-11-26 14:53:55 -05:00

This directory contains the source code of the rust project, including:

  • The test suite
  • The bootstrapping build system
  • Various submodules for tools, like rustdoc, rls, etc.

For more information on how various parts of the compiler work, see the rustc dev guide.