Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unused bucket map direct add/unref calls #30942

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions bucket_map/src/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,22 +256,6 @@ impl<'b, T: Clone + Copy + 'static> Bucket<T> {
Err(BucketMapError::IndexNoSpace(index.capacity_pow2))
}

pub fn addref(&mut self, key: &Pubkey) -> Option<RefCount> {
if let Ok((Some(elem), _)) = Self::find_index_entry_mut(&mut self.index, key, self.random) {
elem.ref_count += 1;
return Some(elem.ref_count);
}
None
}

pub fn unref(&mut self, key: &Pubkey) -> Option<RefCount> {
if let Ok((Some(elem), _)) = Self::find_index_entry_mut(&mut self.index, key, self.random) {
elem.ref_count -= 1;
return Some(elem.ref_count);
}
None
}

pub fn read_value(&self, key: &Pubkey) -> Option<(&[T], RefCount)> {
//debug!("READ_VALUE: {:?}", key);
let (elem, _) = self.find_index_entry(key)?;
Expand Down
12 changes: 0 additions & 12 deletions bucket_map/src/bucket_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,6 @@ impl<T: Clone + Copy> BucketApi<T> {
bucket
}

pub fn addref(&self, key: &Pubkey) -> Option<RefCount> {
self.get_write_bucket()
.as_mut()
.and_then(|bucket| bucket.addref(key))
}

pub fn unref(&self, key: &Pubkey) -> Option<RefCount> {
self.get_write_bucket()
.as_mut()
.and_then(|bucket| bucket.unref(key))
}

pub fn insert(&self, pubkey: &Pubkey, value: (&[T], RefCount)) {
let mut bucket = self.get_write_bucket();
bucket.as_mut().unwrap().insert(pubkey, value)
Expand Down
22 changes: 1 addition & 21 deletions bucket_map/src/bucket_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,6 @@ impl<T: Clone + Copy + Debug> BucketMap<T> {
0
}
}

/// Increment the refcount for Pubkey `key`
pub fn addref(&self, key: &Pubkey) -> Option<RefCount> {
let ix = self.bucket_ix(key);
let bucket = &self.buckets[ix];
bucket.addref(key)
}

/// Decrement the refcount for Pubkey `key`
pub fn unref(&self, key: &Pubkey) -> Option<RefCount> {
let ix = self.bucket_ix(key);
let bucket = &self.buckets[ix];
bucket.unref(key)
}
}

/// Look at the first 8 bytes of the input and reinterpret them as a u64
Expand Down Expand Up @@ -498,13 +484,7 @@ mod tests {
rc = if inc { rc + 1 } else { rc - 1 };
hm.insert(k, (v.to_vec(), rc));
maps.iter().for_each(|map| {
if thread_rng().gen_range(0, 2) == 0 {
map.update(&k, |current| Some((current.unwrap().0.to_vec(), rc)))
} else if inc {
map.addref(&k);
} else {
map.unref(&k);
}
map.update(&k, |current| Some((current.unwrap().0.to_vec(), rc)))
});

return_key(k);
Expand Down