rust/compiler
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
..
rustc Remove useless #[global_allocator] from rustc and rustdoc. 2021-12-23 17:23:21 +11:00
rustc_apfloat Stabilize iter::zip. 2021-12-14 18:50:31 -04:00
rustc_arena Add some comments. 2021-11-19 07:52:59 +11:00
rustc_ast Auto merge of #92294 - Kobzol:rustdoc-meta-kind, r=GuillaumeGomez 2022-01-01 02:03:23 +00:00
rustc_ast_lowering Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwU 2022-01-04 21:23:06 +01:00
rustc_ast_passes Move PatKind::Lit checking from ast_validation to ast lowering 2022-01-01 15:10:43 -05:00
rustc_ast_pretty Rollup merge of #92418 - dtolnay:emptystructpat, r=michaelwoerister 2022-01-03 14:44:20 +01:00
rustc_attr Remove unnecessary sigils around Symbol::as_str() calls. 2021-12-15 17:32:14 +11:00
rustc_borrowck Rollup merge of #90102 - nbdd0121:box3, r=jonas-schievink 2022-01-03 14:44:15 +01:00
rustc_builtin_macros Auto merge of #92066 - Smittyvb:concat_bytes-repeat, r=nagisa 2022-01-02 12:38:41 +00:00
rustc_codegen_cranelift Rollup merge of #90102 - nbdd0121:box3, r=jonas-schievink 2022-01-03 14:44:15 +01:00
rustc_codegen_gcc Update references to -Z symbol-mangling-version to use -C 2022-01-01 15:53:11 -08:00
rustc_codegen_llvm RustWrapper: adapt for an LLVM API change 2022-01-03 11:25:33 +01:00
rustc_codegen_ssa Rollup merge of #92107 - nikic:rmeta-lnk-remove, r=nagisa 2022-01-04 16:34:15 +01:00
rustc_const_eval rename StackPopClean::None to Root 2022-01-04 11:13:08 +01:00
rustc_data_structures Do not hash zero bytes of i64 and u32 in Sip128 hasher 2022-01-04 19:12:10 +01:00
rustc_driver Upgrade tracing-subscriber 2021-12-22 10:47:36 -06:00
rustc_error_codes docs(error-codes): Add long error explanation for E0227 2021-12-28 15:46:20 +03:00
rustc_errors Stabilize iter::zip. 2021-12-14 18:50:31 -04:00
rustc_expand Rollup merge of #91519 - petrochenkov:cratexp2, r=Aaron1011 2021-12-30 13:12:33 +01:00
rustc_feature Stabilize destructuring_assignment 2021-12-14 22:38:51 -05:00
rustc_fs_util Migrate to 2021 2021-09-20 22:21:42 -04:00
rustc_graphviz fix clippy::single_char_pattern perf findings 2021-12-14 12:40:28 +01:00
rustc_hir Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwU 2022-01-04 21:23:06 +01:00
rustc_hir_pretty Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwU 2022-01-04 21:23:06 +01:00
rustc_incremental Add #[rustc_clean(loaded_from_disk)] to assert loading of query result 2021-12-21 16:34:12 -05:00
rustc_index Introduce IntervalSet 2021-12-30 22:33:44 -05:00
rustc_infer Suggest changing quotes when str/char type mismatch 2022-01-03 22:08:08 -08:00
rustc_interface Auto merge of #90128 - joshtriplett:stabilize-symbol-mangling-version, r=wesleywiser 2022-01-02 15:49:23 +00:00
rustc_lexer Auto merge of #91393 - Julian-Wollersberger:lexer_optimization, r=petrochenkov 2021-12-03 13:20:14 +00:00
rustc_lint Rollup merge of #91770 - TaKO8Ki:suggest-adding-cfg-test, r=joshtriplett 2021-12-21 08:33:39 +01:00
rustc_lint_defs Rollup merge of #91770 - TaKO8Ki:suggest-adding-cfg-test, r=joshtriplett 2021-12-21 08:33:39 +01:00
rustc_llvm RustWrapper: adapt for an LLVM API change 2022-01-03 11:25:33 +01:00
rustc_macros Rollup merge of #92011 - Aaron1011:decode-span, r=michaelwoerister 2022-01-03 14:44:16 +01:00
rustc_metadata Auto merge of #90128 - joshtriplett:stabilize-symbol-mangling-version, r=wesleywiser 2022-01-02 15:49:23 +00:00
rustc_middle revert #92254 "Bump gsgdt to 0.1.3" 2022-01-03 20:25:46 +01:00
rustc_mir_build Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwU 2022-01-04 21:23:06 +01:00
rustc_mir_dataflow Rollup merge of #90102 - nbdd0121:box3, r=jonas-schievink 2022-01-03 14:44:15 +01:00
rustc_mir_transform rename StackPopClean::None to Root 2022-01-04 11:13:08 +01:00
rustc_monomorphize Rollup merge of #90102 - nbdd0121:box3, r=jonas-schievink 2022-01-03 14:44:15 +01:00
rustc_parse Parse and suggest moving where clauses after equals for type aliases 2021-12-28 14:20:15 -05:00
rustc_parse_format Migrate to 2021 2021-09-20 22:21:42 -04:00
rustc_passes Add Attribute::meta_kind 2021-12-26 16:56:34 +01:00
rustc_plugin_impl replace dynamic library module with libloading 2021-12-06 12:03:47 -05:00
rustc_privacy Rollup merge of #90586 - jswrenn:relax-privacy-lints, r=petrochenkov 2021-12-27 21:42:25 +01:00
rustc_query_impl Import SourceFiles from crate before decoding foreign Span 2021-12-23 12:56:12 -05:00
rustc_query_system Auto merge of #92259 - Aaron1011:normal-mod-hashing, r=michaelwoerister 2022-01-04 00:25:23 +00:00
rustc_resolve Rollup merge of #92402 - pr2502:while-let-typo, r=oli-obk 2022-01-03 14:44:18 +01:00
rustc_save_analysis review 2022-01-03 11:59:01 +01:00
rustc_serialize Do not use LEB128 for encoding u16 and i16 2021-12-28 09:29:08 +01:00
rustc_session Update references to -Z symbol-mangling-version to use -C 2022-01-01 15:53:11 -08:00
rustc_span Auto merge of #92179 - Aaron1011:incr-loaded-from-disk, r=michaelwoerister 2022-01-03 11:20:08 +00:00
rustc_symbol_mangling Update references to -Z symbol-mangling-version to use -C 2022-01-01 15:53:11 -08:00
rustc_target Auto merge of #92099 - matthiaskrgr:rollup-4gwv67m, r=matthiaskrgr 2021-12-19 12:36:56 +00:00
rustc_trait_selection Auto merge of #92244 - petrochenkov:alltraits, r=cjgillot 2021-12-29 19:22:33 +00:00
rustc_traits Auto merge of #91929 - anuvratsingh:remove_in_band_lifetimes_compiler_rustc_traits, r=jackh726 2021-12-31 05:08:24 +00:00
rustc_ty_utils Use a const ParamEnv when in default_method_body_is_const 2021-12-17 20:42:48 +08:00
rustc_type_ir Fix HashStable implementation on InferTy 2021-12-13 20:36:17 -08:00
rustc_typeck Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwU 2022-01-04 21:23:06 +01:00