rust/compiler
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
..
rustc fix link 2023-03-11 10:53:47 -06:00
rustc_abi Store hashes in special types so they aren't accidentally encoded as numbers 2023-04-18 10:52:47 -04:00
rustc_apfloat
rustc_arena Allow clippy::from_mut_ref 2023-04-09 22:29:56 +02:00
rustc_ast Rollup merge of #110394 - scottmcm:less-idx-new, r=WaffleLapkin 2023-04-17 18:13:35 +02:00
rustc_ast_lowering Use Item::expect_* and ImplItem::expect_* more 2023-04-17 18:00:27 +00:00
rustc_ast_passes Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_ast_pretty Remove .. from return type notation 2023-04-10 22:19:46 +00:00
rustc_attr Bless tidy 2023-03-27 18:58:07 +00:00
rustc_baked_icu_data update ICU4X to 1.1.0 2023-02-04 22:28:59 +01:00
rustc_borrowck Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_builtin_macros fix clippy::toplevel_ref_arg and ::manual_map 2023-04-16 13:28:13 +02:00
rustc_codegen_cranelift Remove from cranelift too. 2023-04-14 16:26:11 +00:00
rustc_codegen_gcc Auto merge of #109989 - ids1024:m68k-asm, r=Amanieu 2023-04-13 11:41:57 +00:00
rustc_codegen_llvm Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot 2023-04-18 22:27:15 +00:00
rustc_codegen_ssa Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot 2023-04-18 22:27:15 +00:00
rustc_const_eval Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot 2023-04-18 22:27:15 +00:00
rustc_data_structures Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot 2023-04-18 22:27:15 +00:00
rustc_driver Remove unneeded extern crate 2023-02-02 07:47:39 +01:00
rustc_driver_impl Rollup merge of #110072 - joshtriplett:stabilize-is-terminal, r=Mark-Simulacrum 2023-04-13 11:21:00 +02:00
rustc_error_codes Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_error_messages migrate ftl msg accroding to #103042 2023-04-13 09:43:46 +08:00
rustc_errors Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot 2023-04-18 22:27:15 +00:00
rustc_expand Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_feature Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_fs_util Add try_canonicalize to rustc_fs_util and use it over fs::canonicalize 2023-03-16 21:50:23 +01:00
rustc_graphviz Fix uninlined_format_args for some compiler crates 2023-01-05 19:01:12 +01:00
rustc_hir Store hashes in special types so they aren't accidentally encoded as numbers 2023-04-18 10:52:47 -04:00
rustc_hir_analysis Rollup merge of #110417 - jsoref:spelling-compiler, r=Nilstrieb 2023-04-18 14:50:51 +02:00
rustc_hir_pretty Remove identity casts 2023-04-09 23:22:14 +02:00
rustc_hir_typeck Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_incremental Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot 2023-04-18 22:27:15 +00:00
rustc_index Fix some clippy::complexity 2023-04-09 23:22:14 +02:00
rustc_infer Rollup merge of #110417 - jsoref:spelling-compiler, r=Nilstrieb 2023-04-18 14:50:51 +02:00
rustc_interface Migrate sess.opts.tests uses to sess.is_test_crate() 2023-04-09 21:37:31 +02:00
rustc_lexer Revert "Don't recover lifetimes/labels containing emojis as character literals" 2023-04-10 06:52:41 +00:00
rustc_lint Rollup merge of #110441 - kadiwa4:typos, r=thomcc 2023-04-18 14:50:51 +02:00
rustc_lint_defs Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_llvm Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_log Stabilize IsTerminal 2023-04-10 17:24:23 +09:00
rustc_macros Rollup merge of #109665 - fee1-dead-contrib:rm-remap-queries, r=oli-obk 2023-04-16 18:55:38 +08:00
rustc_metadata Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot 2023-04-18 22:27:15 +00:00
rustc_middle Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot 2023-04-18 22:27:15 +00:00
rustc_mir_build Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_mir_dataflow Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_mir_transform Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot 2023-04-18 22:27:15 +00:00
rustc_monomorphize Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_parse Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_parse_format Fix typos in compiler 2023-04-10 22:02:52 +02:00
rustc_passes Allow all associated functions and add test 2023-04-16 06:31:08 +00:00
rustc_plugin_impl expand: Pass ast::Crate by reference to AST transforming passes 2023-03-23 14:20:55 +04:00
rustc_privacy resolve: Pre-compute non-reexport module children 2023-04-12 15:22:03 +03:00
rustc_query_impl Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot 2023-04-18 22:27:15 +00:00
rustc_query_system Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot 2023-04-18 22:27:15 +00:00
rustc_resolve Auto merge of #109772 - petrochenkov:slimchild, r=cjgillot 2023-04-18 20:16:56 +00:00
rustc_serialize Remove f32 & f64 from MemDecoder/MemEncoder 2023-04-06 00:54:07 -07:00
rustc_session Store hashes in special types so they aren't accidentally encoded as numbers 2023-04-18 10:52:47 -04:00
rustc_smir Add a stable MIR way to get the main function 2023-04-14 07:28:56 +00:00
rustc_span Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot 2023-04-18 22:27:15 +00:00
rustc_symbol_mangling Store hashes in special types so they aren't accidentally encoded as numbers 2023-04-18 10:52:47 -04:00
rustc_target Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_trait_selection Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_traits Rollup merge of #110345 - nnethercote:rm-Super-impls-for-Region, r=compiler-errors 2023-04-16 18:55:38 +08:00
rustc_transmute Erase regions when confirming transmutability candidate 2023-04-16 19:12:34 +00:00
rustc_ty_utils Spelling - compiler 2023-04-17 16:09:18 -04:00
rustc_type_ir Rollup merge of #110386 - nnethercote:clean-up-traversal-macros, r=lcnr 2023-04-17 18:13:35 +02:00