summaryrefslogtreecommitdiffstats
path: root/vendor/ahash
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:42 +0000
commit837b550238aa671a591ccf282dddeab29cadb206 (patch)
tree914b6b8862bace72bd3245ca184d374b08d8a672 /vendor/ahash
parentAdding debian version 1.70.0+dfsg2-1. (diff)
downloadrustc-837b550238aa671a591ccf282dddeab29cadb206.tar.xz
rustc-837b550238aa671a591ccf282dddeab29cadb206.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/ahash')
-rw-r--r--vendor/ahash/.cargo-checksum.json2
-rw-r--r--vendor/ahash/Cargo.toml2
-rw-r--r--vendor/ahash/README.md2
-rw-r--r--vendor/ahash/src/hash_map.rs3
-rw-r--r--vendor/ahash/src/hash_quality_test.rs14
-rw-r--r--vendor/ahash/src/hash_set.rs1
-rw-r--r--vendor/ahash/src/random_state.rs1
-rw-r--r--vendor/ahash/tests/bench.rs147
8 files changed, 49 insertions, 123 deletions
diff --git a/vendor/ahash/.cargo-checksum.json b/vendor/ahash/.cargo-checksum.json
index f49de138d..305ffa617 100644
--- a/vendor/ahash/.cargo-checksum.json
+++ b/vendor/ahash/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"8eb7fc9d3e5ba10dbc6400f61c380b208502c7b1390fb683ed947765822c0cbb","FAQ.md":"9eb41898523ee209a0a937f9bcb78afe45ad55ca0556f8a4d4063558098f6d1e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0444c6991eead6822f7b9102e654448d51624431119546492e8b231db42c48bb","README.md":"c66723dab78f118b9f0aeb09923c03ed46cd4596757cac9a0ed6bd91a3aea6cc","build.rs":"21e62c29f64f294a6871b5f0831b789cadc5f8e4e02423ab9acccb30c4d401bd","rustfmt.toml":"e090969e99df9360705680cc0097cfaddae10c22dc2e01470592cf3b9787fd36","src/aes_hash.rs":"1392355b354446bd71d9bfcf654b8209210974268db658f8f30c10594b7e421f","src/convert.rs":"b47fc60fc47b3492235da337d4ba247bd80a3e0b5e468d34784db24f1f294244","src/fallback_hash.rs":"37cb76793cd11f0b582e89c91ffaeb7270ed31c90b3a3c082a87ccbe9b188fcc","src/hash_map.rs":"08e05937577ea797d9f8efcdbe45c3dcb1c6f6b71434d27284b139d16b5058bd","src/hash_quality_test.rs":"f603f13f5e7d67f0aa197066555bb8c990e2ce6a3ab5393b551a154920e6fcff","src/hash_set.rs":"f91aeb3d6c07d437a011a3cc88d74d50083e24c553b8dff227706543efa29803","src/lib.rs":"940ab09005f8e98b01ad40da35b69e0fb2de998d58960ed501d24568f3d9f363","src/operations.rs":"605b0bfadf8d4abb4416c33a056cfefc694f6de60591a8fd39bb5a12e91a3286","src/random_state.rs":"5e097a409381f2f46be7f9946d007d6fd3ae7dc5b9443a03b3714a7057826578","src/specialize.rs":"56354db8a0f7e6ee1340a08f2ab6f79a0ff439fd61badac5e7e59fe4f4a653ba","tests/bench.rs":"eae408c803fdf65ac27043dfb4c6d723496a9e5a45f69f8ee92bba9c719d455b","tests/map_tests.rs":"6161e7255fc22977ad871d8bcf948717a8b57b503033d9ddb565f3b145ccab34","tests/nopanic.rs":"0d28a46248d77283941db1d9fd154c68b965c81a0e3db1fe4a43e06fc448da8f"},"package":"bf6ccdb167abbf410dcb915cabd428929d7f6a04980b54a11f26a39f1c7f7107"} \ No newline at end of file
+{"files":{"Cargo.toml":"136a7b1e64c2da6e4b948e9bb7d2429453b7a89cffc3828b9a81584716d22e2f","FAQ.md":"9eb41898523ee209a0a937f9bcb78afe45ad55ca0556f8a4d4063558098f6d1e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0444c6991eead6822f7b9102e654448d51624431119546492e8b231db42c48bb","README.md":"40d63866ffeabb0ae8fd65715f1da447ace146379ecc5c11fc61a84995edeaff","build.rs":"21e62c29f64f294a6871b5f0831b789cadc5f8e4e02423ab9acccb30c4d401bd","rustfmt.toml":"e090969e99df9360705680cc0097cfaddae10c22dc2e01470592cf3b9787fd36","src/aes_hash.rs":"1392355b354446bd71d9bfcf654b8209210974268db658f8f30c10594b7e421f","src/convert.rs":"b47fc60fc47b3492235da337d4ba247bd80a3e0b5e468d34784db24f1f294244","src/fallback_hash.rs":"37cb76793cd11f0b582e89c91ffaeb7270ed31c90b3a3c082a87ccbe9b188fcc","src/hash_map.rs":"5ee97baa64fa528ba9c01bd018332c4974846c4813c6f8c30cee9f3546598f1c","src/hash_quality_test.rs":"4396264603d0739f1464b191019f4c7c5b2ffe511ca375bc63de3e6a3a113958","src/hash_set.rs":"360e55d066b44624f06e49efa140c03fda635fb17a59622cc29a83830bd1f263","src/lib.rs":"940ab09005f8e98b01ad40da35b69e0fb2de998d58960ed501d24568f3d9f363","src/operations.rs":"605b0bfadf8d4abb4416c33a056cfefc694f6de60591a8fd39bb5a12e91a3286","src/random_state.rs":"fefae5d124933163abf69471589758870ab4e387a2142c7d94f545de9b1f6b20","src/specialize.rs":"56354db8a0f7e6ee1340a08f2ab6f79a0ff439fd61badac5e7e59fe4f4a653ba","tests/bench.rs":"6455dedf9db9fb03b2ea4a5a4b9efbeeee3ac3019c66d68dcb0560e3e58ff8e3","tests/map_tests.rs":"6161e7255fc22977ad871d8bcf948717a8b57b503033d9ddb565f3b145ccab34","tests/nopanic.rs":"0d28a46248d77283941db1d9fd154c68b965c81a0e3db1fe4a43e06fc448da8f"},"package":"2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"} \ No newline at end of file
diff --git a/vendor/ahash/Cargo.toml b/vendor/ahash/Cargo.toml
index e251c700b..a027c55a5 100644
--- a/vendor/ahash/Cargo.toml
+++ b/vendor/ahash/Cargo.toml
@@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "ahash"
-version = "0.8.2"
+version = "0.8.3"
authors = ["Tom Kaitchuck <Tom.Kaitchuck@gmail.com>"]
build = "./build.rs"
exclude = [
diff --git a/vendor/ahash/README.md b/vendor/ahash/README.md
index efab7b270..18c421dbb 100644
--- a/vendor/ahash/README.md
+++ b/vendor/ahash/README.md
@@ -1,4 +1,4 @@
-# aHash ![Build Status](https://img.shields.io/github/workflow/status/tkaitchuck/ahash/Rust) ![Licence](https://img.shields.io/crates/l/ahash) ![Downloads](https://img.shields.io/crates/d/ahash)
+# aHash ![Build Status](https://img.shields.io/github/actions/workflow/status/tkaitchuck/aHash/rust.yml?branch=master) ![Licence](https://img.shields.io/crates/l/ahash) ![Downloads](https://img.shields.io/crates/d/ahash)
AHash is the [fastest](https://github.com/tkaitchuck/aHash/blob/master/compare/readme.md#Speed),
[DOS resistant hash](https://github.com/tkaitchuck/aHash/wiki/How-aHash-is-resists-DOS-attacks) currently available in Rust.
diff --git a/vendor/ahash/src/hash_map.rs b/vendor/ahash/src/hash_map.rs
index c1cb57d10..2b6fbdc89 100644
--- a/vendor/ahash/src/hash_map.rs
+++ b/vendor/ahash/src/hash_map.rs
@@ -1,6 +1,6 @@
use std::borrow::Borrow;
-use std::collections::{hash_map, HashMap};
use std::collections::hash_map::{IntoKeys, IntoValues};
+use std::collections::{hash_map, HashMap};
use std::fmt::{self, Debug};
use std::hash::{BuildHasher, Hash};
use std::iter::FromIterator;
@@ -14,7 +14,6 @@ use serde::{
};
use crate::RandomState;
-use crate::random_state::RandomSource;
/// A [`HashMap`](std::collections::HashMap) using [`RandomState`](crate::RandomState) to hash the items.
/// (Requires the `std` feature to be enabled.)
diff --git a/vendor/ahash/src/hash_quality_test.rs b/vendor/ahash/src/hash_quality_test.rs
index bd85eddda..8f13d2421 100644
--- a/vendor/ahash/src/hash_quality_test.rs
+++ b/vendor/ahash/src/hash_quality_test.rs
@@ -50,7 +50,7 @@ fn count_same_bytes_and_nibbles(a: u64, b: u64) -> (i32, i32) {
(same_byte_count, same_nibble_count)
}
-fn gen_combinations(options: &[u32; 8], depth: u32, so_far: Vec<u32>, combinations: &mut Vec<Vec<u32>>) {
+fn gen_combinations(options: &[u32; 11], depth: u32, so_far: Vec<u32>, combinations: &mut Vec<Vec<u32>>) {
if depth == 0 {
return;
}
@@ -63,8 +63,9 @@ fn gen_combinations(options: &[u32; 8], depth: u32, so_far: Vec<u32>, combinatio
}
fn test_no_full_collisions<T: Hasher>(gen_hash: impl Fn() -> T) {
- let options: [u32; 8] = [
- 0x00000000, 0x20000000, 0x40000000, 0x60000000, 0x80000000, 0xA0000000, 0xC0000000, 0xE0000000,
+ let options: [u32; 11] = [
+ 0x00000000, 0x10000000, 0x20000000, 0x40000000, 0x80000000, 0xF0000000,
+ 1, 2, 4, 8, 15
];
let mut combinations = Vec::new();
gen_combinations(&options, 7, Vec::new(), &mut combinations);
@@ -89,7 +90,7 @@ fn test_no_full_collisions<T: Hasher>(gen_hash: impl Fn() -> T) {
map.insert(hash, array);
}
}
- assert_eq!(2396744, map.len());
+ assert_eq!(21435887, map.len()); //11^7 + 11^6 ...
}
fn test_keys_change_output<T: Hasher>(constructor: impl Fn(u128, u128) -> T) {
@@ -150,9 +151,10 @@ fn assert_each_byte_differs(num: u64, base: u64, alternitives: Vec<u64>) {
assert_eq!(
core::u64::MAX,
changed_bits,
- "Bits changed: {:x} on num: {:?}",
+ "Bits changed: {:x} on num: {:?}. base {:x}",
changed_bits,
- num
+ num,
+ base
);
}
diff --git a/vendor/ahash/src/hash_set.rs b/vendor/ahash/src/hash_set.rs
index 8d1341a14..d03bef580 100644
--- a/vendor/ahash/src/hash_set.rs
+++ b/vendor/ahash/src/hash_set.rs
@@ -1,5 +1,4 @@
use crate::RandomState;
-use crate::random_state::RandomSource;
use std::collections::{hash_set, HashSet};
use std::fmt::{self, Debug};
use std::hash::{BuildHasher, Hash};
diff --git a/vendor/ahash/src/random_state.rs b/vendor/ahash/src/random_state.rs
index e885fa44e..54b754d8d 100644
--- a/vendor/ahash/src/random_state.rs
+++ b/vendor/ahash/src/random_state.rs
@@ -103,6 +103,7 @@ cfg_if::cfg_if! {
&RAND
}
} else {
+ #[inline]
fn get_fixed_seeds() -> &'static [[u64; 4]; 2] {
&[PI, PI2]
}
diff --git a/vendor/ahash/tests/bench.rs b/vendor/ahash/tests/bench.rs
index 84a373959..5bc0fc978 100644
--- a/vendor/ahash/tests/bench.rs
+++ b/vendor/ahash/tests/bench.rs
@@ -3,60 +3,33 @@
use ahash::{AHasher, RandomState};
use criterion::*;
use fxhash::FxHasher;
+use rand::Rng;
use std::collections::hash_map::DefaultHasher;
use std::hash::{BuildHasherDefault, Hash, Hasher};
-#[cfg(any(
- all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)),
+// Needs to be in sync with `src/lib.rs`
+const AHASH_IMPL: &str = if cfg!(any(
all(
- any(target_arch = "arm", target_arch = "aarch64"),
- any(target_feature = "aes", target_feature = "crypto"),
- not(miri),
- feature = "stdsimd"
- )
-))]
-fn aeshash<H: Hash>(b: &H) -> u64 {
- let build_hasher = RandomState::with_seeds(1, 2, 3, 4);
- build_hasher.hash_one(b)
-}
-#[cfg(not(any(
- all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)),
- all(
- any(target_arch = "arm", target_arch = "aarch64"),
- any(target_feature = "aes", target_feature = "crypto"),
+ any(target_arch = "x86", target_arch = "x86_64"),
+ target_feature = "aes",
not(miri),
- feature = "stdsimd"
- )
-)))]
-fn aeshash<H: Hash>(_b: &H) -> u64 {
- panic!("aes must be enabled")
-}
-
-#[cfg(not(any(
- all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)),
+ ),
all(
any(target_arch = "arm", target_arch = "aarch64"),
any(target_feature = "aes", target_feature = "crypto"),
not(miri),
- feature = "stdsimd"
- )
-)))]
-fn fallbackhash<H: Hash>(b: &H) -> u64 {
+ feature = "stdsimd",
+ ),
+)) {
+ "aeshash"
+} else {
+ "fallbackhash"
+};
+
+fn ahash<H: Hash>(b: &H) -> u64 {
let build_hasher = RandomState::with_seeds(1, 2, 3, 4);
build_hasher.hash_one(b)
}
-#[cfg(any(
- all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)),
- all(
- any(target_arch = "arm", target_arch = "aarch64"),
- any(target_feature = "aes", target_feature = "crypto"),
- not(miri),
- feature = "stdsimd"
- )
-))]
-fn fallbackhash<H: Hash>(_b: &H) -> u64 {
- panic!("aes must be disabled")
-}
fn fnvhash<H: Hash>(b: &H) -> u64 {
let mut hasher = fnv::FnvHasher::default();
@@ -98,72 +71,44 @@ fn gen_strings() -> Vec<String> {
.collect()
}
-const U8_VALUE: u8 = 123;
-const U16_VALUE: u16 = 1234;
-const U32_VALUE: u32 = 12345678;
-const U64_VALUE: u64 = 1234567890123456;
-const U128_VALUE: u128 = 12345678901234567890123456789012;
+macro_rules! bench_inputs {
+ ($group:ident, $hash:ident) => {
+ // Number of iterations per batch should be high enough to hide timing overhead.
+ let size = BatchSize::NumIterations(2_000);
-#[cfg(target_feature = "aes")]
-fn bench_ahash(c: &mut Criterion) {
- let mut group = c.benchmark_group("aeshash");
- group.bench_with_input("u8", &U8_VALUE, |b, s| b.iter(|| black_box(aeshash(s))));
- group.bench_with_input("u16", &U16_VALUE, |b, s| b.iter(|| black_box(aeshash(s))));
- group.bench_with_input("u32", &U32_VALUE, |b, s| b.iter(|| black_box(aeshash(s))));
- group.bench_with_input("u64", &U64_VALUE, |b, s| b.iter(|| black_box(aeshash(s))));
- group.bench_with_input("u128", &U128_VALUE, |b, s| b.iter(|| black_box(aeshash(s))));
- group.bench_with_input("string", &gen_strings(), |b, s| b.iter(|| black_box(aeshash(s))));
+ let mut rng = rand::thread_rng();
+ $group.bench_function("u8", |b| b.iter_batched(|| rng.gen::<u8>(), |v| $hash(&v), size));
+ $group.bench_function("u16", |b| b.iter_batched(|| rng.gen::<u16>(), |v| $hash(&v), size));
+ $group.bench_function("u32", |b| b.iter_batched(|| rng.gen::<u32>(), |v| $hash(&v), size));
+ $group.bench_function("u64", |b| b.iter_batched(|| rng.gen::<u64>(), |v| $hash(&v), size));
+ $group.bench_function("u128", |b| b.iter_batched(|| rng.gen::<u128>(), |v| $hash(&v), size));
+ $group.bench_with_input("strings", &gen_strings(), |b, s| b.iter(|| $hash(black_box(s))));
+ };
}
-#[cfg(not(target_feature = "aes"))]
-fn bench_fallback(c: &mut Criterion) {
- let mut group = c.benchmark_group("fallback");
- group.bench_with_input("u8", &U8_VALUE, |b, s| b.iter(|| black_box(fallbackhash(s))));
- group.bench_with_input("u16", &U16_VALUE, |b, s| b.iter(|| black_box(fallbackhash(s))));
- group.bench_with_input("u32", &U32_VALUE, |b, s| b.iter(|| black_box(fallbackhash(s))));
- group.bench_with_input("u64", &U64_VALUE, |b, s| b.iter(|| black_box(fallbackhash(s))));
- group.bench_with_input("u128", &U128_VALUE, |b, s| b.iter(|| black_box(fallbackhash(s))));
- group.bench_with_input("string", &gen_strings(), |b, s| b.iter(|| black_box(fallbackhash(s))));
+fn bench_ahash(c: &mut Criterion) {
+ let mut group = c.benchmark_group(AHASH_IMPL);
+ bench_inputs!(group, ahash);
}
fn bench_fx(c: &mut Criterion) {
let mut group = c.benchmark_group("fx");
- group.bench_with_input("u8", &U8_VALUE, |b, s| b.iter(|| black_box(fxhash(s))));
- group.bench_with_input("u16", &U16_VALUE, |b, s| b.iter(|| black_box(fxhash(s))));
- group.bench_with_input("u32", &U32_VALUE, |b, s| b.iter(|| black_box(fxhash(s))));
- group.bench_with_input("u64", &U64_VALUE, |b, s| b.iter(|| black_box(fxhash(s))));
- group.bench_with_input("u128", &U128_VALUE, |b, s| b.iter(|| black_box(fxhash(s))));
- group.bench_with_input("string", &gen_strings(), |b, s| b.iter(|| black_box(fxhash(s))));
+ bench_inputs!(group, fxhash);
}
fn bench_fnv(c: &mut Criterion) {
let mut group = c.benchmark_group("fnv");
- group.bench_with_input("u8", &U8_VALUE, |b, s| b.iter(|| black_box(fnvhash(s))));
- group.bench_with_input("u16", &U16_VALUE, |b, s| b.iter(|| black_box(fnvhash(s))));
- group.bench_with_input("u32", &U32_VALUE, |b, s| b.iter(|| black_box(fnvhash(s))));
- group.bench_with_input("u64", &U64_VALUE, |b, s| b.iter(|| black_box(fnvhash(s))));
- group.bench_with_input("u128", &U128_VALUE, |b, s| b.iter(|| black_box(fnvhash(s))));
- group.bench_with_input("string", &gen_strings(), |b, s| b.iter(|| black_box(fnvhash(s))));
+ bench_inputs!(group, fnvhash);
}
fn bench_sea(c: &mut Criterion) {
let mut group = c.benchmark_group("sea");
- group.bench_with_input("u8", &U8_VALUE, |b, s| b.iter(|| black_box(seahash(s))));
- group.bench_with_input("u16", &U16_VALUE, |b, s| b.iter(|| black_box(seahash(s))));
- group.bench_with_input("u32", &U32_VALUE, |b, s| b.iter(|| black_box(seahash(s))));
- group.bench_with_input("u64", &U64_VALUE, |b, s| b.iter(|| black_box(seahash(s))));
- group.bench_with_input("u128", &U128_VALUE, |b, s| b.iter(|| black_box(seahash(s))));
- group.bench_with_input("string", &gen_strings(), |b, s| b.iter(|| black_box(seahash(s))));
+ bench_inputs!(group, seahash);
}
fn bench_sip(c: &mut Criterion) {
let mut group = c.benchmark_group("sip");
- group.bench_with_input("u8", &U8_VALUE, |b, s| b.iter(|| black_box(siphash(s))));
- group.bench_with_input("u16", &U16_VALUE, |b, s| b.iter(|| black_box(siphash(s))));
- group.bench_with_input("u32", &U32_VALUE, |b, s| b.iter(|| black_box(siphash(s))));
- group.bench_with_input("u64", &U64_VALUE, |b, s| b.iter(|| black_box(siphash(s))));
- group.bench_with_input("u128", &U128_VALUE, |b, s| b.iter(|| black_box(siphash(s))));
- group.bench_with_input("string", &gen_strings(), |b, s| b.iter(|| black_box(siphash(s))));
+ bench_inputs!(group, siphash);
}
fn bench_map(c: &mut Criterion) {
@@ -242,32 +187,12 @@ fn bench_map(c: &mut Criterion) {
criterion_main!(benches);
-#[cfg(any(
- all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)),
- all(
- any(target_arch = "arm", target_arch = "aarch64"),
- any(target_feature = "aes", target_feature = "crypto"),
- not(miri),
- feature = "stdsimd"
- )
-))]
-criterion_group!(benches, bench_ahash, bench_fx, bench_fnv, bench_sea, bench_sip);
-
-#[cfg(not(any(
- all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)),
- all(
- any(target_arch = "arm", target_arch = "aarch64"),
- any(target_feature = "aes", target_feature = "crypto"),
- not(miri),
- feature = "stdsimd"
- )
-)))]
criterion_group!(
benches,
- bench_fallback,
+ bench_ahash,
bench_fx,
bench_fnv,
bench_sea,
bench_sip,
- bench_map,
+ bench_map
);