Skip to content

Commit

Permalink
Remove FlexZeroVec
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Sep 30, 2024
1 parent c925c81 commit 1265158
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 1,918 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
- This release has multiple changes that affect the bit representation of various types. Do not update to this release if you wish to retain stable data formats.
- Change the `VarZeroVecFormat` values shipped by default to use the same index and length width. This breaks data layout for all `VarZeroVec`s. (https://github.com/unicode-org/icu4x/pull/5594)
- Optimize `MultiFieldsULE` to not store a length anymore. This breaks data layout for any `#[make_varule]`-using struct with multiple variable-sized fields. (https://github.com/unicode-org/icu4x/pull/5593)
- Remove `FlexZeroVec` (https://github.com/unicode-org/icu4x/pull/5604)
- `writeable`


Expand Down
44 changes: 6 additions & 38 deletions utils/zerotrie/benches/overview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ fn get_basic_bench(c: &mut Criterion) {

#[cfg(feature = "bench")]
g.bench_function("ZeroMap/usize", |b| {
let zm: ZeroMap<[u8], usize> = data.iter().copied().collect();
let zm: ZeroMap<[u8], u32> = data.iter().map(|(a, b)| (*a, *b as u32)).collect();
b.iter(|| {
for (key, expected) in black_box(data) {
let actual = black_box(&zm).get_copied(key);
assert_eq!(Some(*expected), actual);
assert_eq!(Some(*expected as u32), actual);
}
});
});
Expand All @@ -88,22 +88,6 @@ fn get_basic_bench(c: &mut Criterion) {
});
});

#[cfg(feature = "bench")]
g.bench_function("ZeroHashMap/usize", |b| {
let zhm: ZeroHashMap<[u8], usize> = data
.iter()
.copied()
.collect();
b.iter(|| {
for (key, expected) in black_box(data) {
let actual = black_box(&zhm).get(key);
// No get_copied on ZHM so we need to do it manually
let actual = actual.map(|x| <zerovec::vecs::FlexZeroSlice as zerovec::maps::ZeroVecLike<usize>>::zvl_get_as_t(x, |y| *y));
assert_eq!(Some(*expected), actual);
}
});
});

#[cfg(feature = "bench")]
g.bench_function("ZeroHashMap/u8", |b| {
let zhm: ZeroHashMap<[u8], u8> = data.iter().map(|(k, v)| (*k, *v as u8)).collect();
Expand Down Expand Up @@ -171,11 +155,11 @@ fn get_subtags_bench_helper<M: criterion::measurement::Measurement>(

#[cfg(feature = "bench")]
g.bench_function("ZeroMap/usize", |b| {
let zm: ZeroMap<[u8], usize> = litemap.iter().map(|(a, b)| (*a, b)).collect();
let zm: ZeroMap<[u8], u32> = litemap.iter().map(|(a, b)| (*a, *b as u32)).collect();
b.iter(|| {
for (i, key) in black_box(strings).iter().enumerate() {
let actual = black_box(&zm).get_copied(key.as_bytes());
assert_eq!(Some(i), actual);
assert_eq!(Some(i as u32), actual);
}
});
});
Expand All @@ -193,27 +177,11 @@ fn get_subtags_bench_helper<M: criterion::measurement::Measurement>(

#[cfg(feature = "bench")]
g.bench_function("HashMap", |b| {
let hm: HashMap<&[u8], usize> = litemap.iter().map(|(a, b)| (*a, *b)).collect();
let hm: HashMap<&[u8], u32> = litemap.iter().map(|(a, b)| (*a, *b as u32)).collect();
b.iter(|| {
for (i, key) in black_box(strings).iter().enumerate() {
let actual = black_box(&hm).get(key.as_bytes());
assert_eq!(Some(&i), actual);
}
});
});

#[cfg(feature = "bench")]
g.bench_function("ZeroHashMap/usize", |b| {
let zhm: ZeroHashMap<[u8], usize> = litemap
.iter()
.map(|(a, b)| (*a, b))
.collect();
b.iter(|| {
for (i, key) in black_box(strings).iter().enumerate() {
let actual = black_box(&zhm).get(key.as_bytes());
// No get_copied on ZHM so we need to do it manually
let actual = actual.map(|x| <zerovec::vecs::FlexZeroSlice as zerovec::maps::ZeroVecLike<usize>>::zvl_get_as_t(x, |y| *y));
assert_eq!(Some(i), actual);
assert_eq!(Some(i as u32), actual.copied());
}
});
});
Expand Down
4 changes: 2 additions & 2 deletions utils/zerotrie/tests/asciitrie_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn test_basic() {
}

// Compare the size to a postcard ZeroMap
let zm: ZeroMap<[u8], usize> = data_ascii.iter().copied().collect();
let zm: ZeroMap<[u8], u32> = data_ascii.iter().map(|(a, b)| (*a, *b as u32)).collect();
let mut serializer = postcard::Serializer {
output: AllocVec::new(),
};
Expand All @@ -69,5 +69,5 @@ fn test_basic() {
.expect("Failed to finalize serializer output");

assert_eq!(26, bytes_ascii.len());
assert_eq!(59, zeromap_bytes.len());
assert_eq!(79, zeromap_bytes.len());
}
27 changes: 15 additions & 12 deletions utils/zerotrie/tests/builder_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,17 +648,18 @@ fn test_everything() {
assert_bytes_eq!(36, trie_phf.as_bytes(), expected_bytes);
check_phf_ascii_trie(&litemap, &trie_phf);

let zhm: zerovec::ZeroMap<[u8], usize> = litemap.iter().map(|(a, b)| (*a, b)).collect();
let zhm: zerovec::ZeroMap<[u8], u32> = litemap.iter().map(|(a, b)| (*a, *b as u32)).collect();
let zhm_buf = postcard::to_allocvec(&zhm).unwrap();
assert_eq!(zhm_buf.len(), 73);
assert_eq!(zhm_buf.len(), 90);

let zhm: zerovec::ZeroMap<[u8], u8> = litemap.iter().map(|(a, b)| (*a, *b as u8)).collect();
let zhm_buf = postcard::to_allocvec(&zhm).unwrap();
assert_eq!(zhm_buf.len(), 63);

let zhm: zerovec::ZeroHashMap<[u8], usize> = litemap.iter().map(|(a, b)| (*a, b)).collect();
let zhm: zerovec::ZeroHashMap<[u8], u32> =
litemap.iter().map(|(a, b)| (*a, *b as u32)).collect();
let zhm_buf = postcard::to_allocvec(&zhm).unwrap();
assert_eq!(zhm_buf.len(), 146);
assert_eq!(zhm_buf.len(), 163);

let zhm: zerovec::ZeroHashMap<[u8], u8> = litemap.iter().map(|(a, b)| (*a, *b as u8)).collect();
let zhm_buf = postcard::to_allocvec(&zhm).unwrap();
Expand Down Expand Up @@ -804,17 +805,18 @@ fn test_short_subtags_10pct() {
assert_eq!(trie_phf.byte_len(), 1100);
check_phf_ascii_trie(&litemap, &trie_phf);

let zhm: zerovec::ZeroMap<[u8], usize> = litemap.iter().map(|(a, b)| (*a, b)).collect();
let zhm: zerovec::ZeroMap<[u8], u32> = litemap.iter().map(|(a, b)| (*a, *b as u32)).collect();
let zhm_buf = postcard::to_allocvec(&zhm).unwrap();
assert_eq!(zhm_buf.len(), 1329);
assert_eq!(zhm_buf.len(), 1892);

let zhm: zerovec::ZeroMap<[u8], u8> = litemap.iter().map(|(a, b)| (*a, *b as u8)).collect();
let zhm_buf = postcard::to_allocvec(&zhm).unwrap();
assert_eq!(zhm_buf.len(), 1328);

let zhm: zerovec::ZeroHashMap<[u8], usize> = litemap.iter().map(|(a, b)| (*a, b)).collect();
let zhm: zerovec::ZeroHashMap<[u8], u32> =
litemap.iter().map(|(a, b)| (*a, *b as u32)).collect();
let zhm_buf = postcard::to_allocvec(&zhm).unwrap();
assert_eq!(zhm_buf.len(), 2835);
assert_eq!(zhm_buf.len(), 3398);

let zhm: zerovec::ZeroHashMap<[u8], u8> = litemap.iter().map(|(a, b)| (*a, *b as u8)).collect();
let zhm_buf = postcard::to_allocvec(&zhm).unwrap();
Expand All @@ -834,17 +836,18 @@ fn test_short_subtags() {
assert_eq!(trie_phf.byte_len(), 9400);
check_phf_ascii_trie(&litemap, &trie_phf);

let zm: zerovec::ZeroMap<[u8], usize> = litemap.iter().map(|(a, b)| (*a, b)).collect();
let zm: zerovec::ZeroMap<[u8], u32> = litemap.iter().map(|(a, b)| (*a, *b as u32)).collect();
let zhm_buf = postcard::to_allocvec(&zm).unwrap();
assert_eq!(zhm_buf.len(), 15180);
assert_eq!(zhm_buf.len(), 18933);

let zm: zerovec::ZeroMap<[u8], u8> = litemap.iter().map(|(a, b)| (*a, *b as u8)).collect();
let zhm_buf = postcard::to_allocvec(&zm).unwrap();
assert_eq!(zhm_buf.len(), 13302);

let zhm: zerovec::ZeroHashMap<[u8], usize> = litemap.iter().map(|(a, b)| (*a, b)).collect();
let zhm: zerovec::ZeroHashMap<[u8], u32> =
litemap.iter().map(|(a, b)| (*a, *b as u32)).collect();
let zhm_buf = postcard::to_allocvec(&zhm).unwrap();
assert_eq!(zhm_buf.len(), 30198);
assert_eq!(zhm_buf.len(), 33951);

let zhm: zerovec::ZeroHashMap<[u8], u8> = litemap.iter().map(|(a, b)| (*a, *b as u8)).collect();
let zhm_buf = postcard::to_allocvec(&zhm).unwrap();
Expand Down
78 changes: 0 additions & 78 deletions utils/zerovec/src/flexzerovec/databake.rs

This file was deleted.

20 changes: 0 additions & 20 deletions utils/zerovec/src/flexzerovec/mod.rs

This file was deleted.

Loading

0 comments on commit 1265158

Please sign in to comment.