rust/compiler/rustc_middle/src
bors b3f1379509 Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot
Encode hashes as bytes, not varint

In a few places, we store hashes as `u64` or `u128` and then apply `derive(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 types `Hash64` and `Hash128` which are produced by `StableHasher` and replace every use of storing a `u64` or `u128` that represents a hash.

Distribution of the byte lengths of leb128 encodings, from `x build --stage 2` with `incremental = true`

Before:
```
(  1) 373418203 (53.7%, 53.7%): 1
(  2) 196240113 (28.2%, 81.9%): 3
(  3) 108157958 (15.6%, 97.5%): 2
(  4)  17213120 ( 2.5%, 99.9%): 4
(  5)    223614 ( 0.0%,100.0%): 9
(  6)    216262 ( 0.0%,100.0%): 10
(  7)     15447 ( 0.0%,100.0%): 5
(  8)      3633 ( 0.0%,100.0%): 19
(  9)      3030 ( 0.0%,100.0%): 8
( 10)      1167 ( 0.0%,100.0%): 18
( 11)      1032 ( 0.0%,100.0%): 7
( 12)      1003 ( 0.0%,100.0%): 6
( 13)        10 ( 0.0%,100.0%): 16
( 14)        10 ( 0.0%,100.0%): 17
( 15)         5 ( 0.0%,100.0%): 12
( 16)         4 ( 0.0%,100.0%): 14
```

After:
```
(  1) 372939136 (53.7%, 53.7%): 1
(  2) 196240140 (28.3%, 82.0%): 3
(  3) 108014969 (15.6%, 97.5%): 2
(  4)  17192375 ( 2.5%,100.0%): 4
(  5)       435 ( 0.0%,100.0%): 5
(  6)        83 ( 0.0%,100.0%): 18
(  7)        79 ( 0.0%,100.0%): 10
(  8)        50 ( 0.0%,100.0%): 9
(  9)         6 ( 0.0%,100.0%): 19
```

The remaining 9 or 10 and 18 or 19 are `u64` and `u128` respectively that have the high bits set. As far as I can tell these are coming primarily from `SwitchTargets`.
2023-04-18 22:27:15 +00:00
..
dep_graph Store hashes in special types so they aren't accidentally encoded as numbers 2023-04-18 10:52:47 -04:00
hir Remove some unnecessary hash truncations 2023-04-16 20:05:02 -04:00
infer Rollup merge of #110386 - nnethercote:clean-up-traversal-macros, r=lcnr 2023-04-17 18:13:35 +02:00
middle Store hashes in special types so they aren't accidentally encoded as numbers 2023-04-18 10:52:47 -04:00
mir Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot 2023-04-18 22:27:15 +00:00
query Rollup merge of #109665 - fee1-dead-contrib:rm-remap-queries, r=oli-obk 2023-04-16 18:55:38 +08:00
thir Add Span to StmtKind::Let. 2023-04-03 15:59:21 +00:00
traits Rollup merge of #110124 - Nilstrieb:📎-told-me-so, r=compiler-errors 2023-04-10 14:13:16 +05:30
ty Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot 2023-04-18 22:27:15 +00:00
util Move some utils out of rustc_const_eval 2023-04-16 12:05:54 +02:00
arena.rs resolve: Preserve reexport chains in ModChildren 2023-04-08 13:29:15 +03:00
error.rs fix(middle): emit error rather than delay bug when reaching limit 2023-04-03 11:08:14 +08:00
lib.rs Auto merge of #110243 - WaffleLapkin:bless_tagged_pointers🙏, r=Nilstrieb 2023-04-17 21:50:13 +00:00
lint.rs create helper function for rustc_lint_defs::Level and remove it's duplicated code r=ozkanonur 2023-01-10 10:56:17 +03:00
macros.rs Simplify CloneLiftImpls and TrivialTypeTraversalImpls. 2023-04-16 14:19:50 +10:00
metadata.rs rustc_metadata: Remove Span from ModChild 2023-04-18 17:25:04 +03:00
tests.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
thir.rs Add Span to StmtKind::Let. 2023-04-03 15:59:21 +00:00
values.rs rustc_middle: Remove trait DefIdTree 2023-03-02 23:46:44 +04:00