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 dc3669f
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 1,911 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
2 changes: 1 addition & 1 deletion 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 Down
15 changes: 9 additions & 6 deletions utils/zerotrie/tests/builder_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,15 +648,16 @@ 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);

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);

Expand Down Expand Up @@ -804,15 +805,16 @@ 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);

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);

Expand All @@ -834,15 +836,16 @@ 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);

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);

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 dc3669f

Please sign in to comment.