Skip to content

Commit 1becb46

Browse files
committed
Remove HashSet initialization with capacity
1 parent f3828fe commit 1becb46

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Reduce the memory usage of the `tag_cardinality_limit` transform when running in `exact` mode by allocating less unused memory on initialization.
2+
3+
authors: ArunPiduguDD

src/transforms/tag_cardinality_limit/tag_value_set.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ impl fmt::Debug for TagValueSetStorage {
6060

6161
impl AcceptedTagValueSet {
6262
pub fn new(value_limit: usize, mode: &Mode) -> Self {
63+
let _ = value_limit; // capacity is grown lazily; `value_limit` only caps `len()` at insert time
6364
let storage = match &mode {
64-
Mode::Exact => TagValueSetStorage::Set(HashSet::with_capacity(value_limit)),
65+
Mode::Exact => TagValueSetStorage::Set(HashSet::new()),
6566
Mode::Probabilistic(config) => {
6667
TagValueSetStorage::Bloom(BloomFilterStorage::new(config.cache_size_per_key))
6768
}

0 commit comments

Comments
 (0)