diff --git a/bucket_map/src/bucket.rs b/bucket_map/src/bucket.rs index 16d28b7f8..c11604527 100644 --- a/bucket_map/src/bucket.rs +++ b/bucket_map/src/bucket.rs @@ -156,22 +156,22 @@ impl<'b, T: Clone + Copy + 'static> Bucket { result } - pub fn find_entry(&self, key: &Pubkey) -> Option<(&IndexEntry, u64)> { - Self::bucket_find_entry(&self.index, key, self.random) + pub fn find_index_entry(&self, key: &Pubkey) -> Option<(&IndexEntry, u64)> { + Self::bucket_find_index_entry(&self.index, key, self.random) } /// find an entry for `key` /// if entry exists, return the entry along with the index of the existing entry /// if entry does not exist, return just the index of an empty entry appropriate for this key /// returns (existing entry, index of the found or empty entry) - fn find_entry_mut<'a>( + fn find_index_entry_mut<'a>( index: &'a mut BucketStorage, key: &Pubkey, random: u64, ) -> Result<(Option<&'a mut IndexEntry>, u64), BucketMapError> { let ix = Self::bucket_index_ix(index, key, random); let mut first_free = None; - let mut m = Measure::start("bucket_find_entry_mut"); + let mut m = Measure::start("bucket_find_index_entry_mut"); let capacity = index.capacity(); for i in ix..ix + index.max_search() { let ii = i % capacity; @@ -187,7 +187,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket { index .stats - .find_entry_mut_us + .find_index_entry_mut_us .fetch_add(m.as_us(), Ordering::Relaxed); return Ok((Some(index.get_mut(ii)), ii)); } @@ -195,7 +195,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket { m.stop(); index .stats - .find_entry_mut_us + .find_index_entry_mut_us .fetch_add(m.as_us(), Ordering::Relaxed); match first_free { Some(ii) => Ok((None, ii)), @@ -203,7 +203,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket { } } - fn bucket_find_entry<'a>( + fn bucket_find_index_entry<'a>( index: &'a BucketStorage, key: &Pubkey, random: u64, @@ -244,20 +244,20 @@ impl<'b, T: Clone + Copy + 'static> Bucket { m.stop(); index .stats - .find_entry_mut_us + .find_index_entry_mut_us .fetch_add(m.as_us(), Ordering::Relaxed); return Ok(ii); } m.stop(); index .stats - .find_entry_mut_us + .find_index_entry_mut_us .fetch_add(m.as_us(), Ordering::Relaxed); Err(BucketMapError::IndexNoSpace(index.capacity_pow2)) } pub fn addref(&mut self, key: &Pubkey) -> Option { - if let Ok((Some(elem), _)) = Self::find_entry_mut(&mut self.index, key, self.random) { + 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); } @@ -265,7 +265,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket { } pub fn unref(&mut self, key: &Pubkey) -> Option { - if let Ok((Some(elem), _)) = Self::find_entry_mut(&mut self.index, key, self.random) { + 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); } @@ -274,7 +274,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket { pub fn read_value(&self, key: &Pubkey) -> Option<(&[T], RefCount)> { //debug!("READ_VALUE: {:?}", key); - let (elem, _) = self.find_entry(key)?; + let (elem, _) = self.find_index_entry(key)?; elem.read_value(self) } @@ -291,7 +291,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket { return Err(BucketMapError::DataNoSpace((best_fit_bucket, 0))); } let max_search = self.index.max_search(); - let (elem, elem_ix) = Self::find_entry_mut(&mut self.index, key, self.random)?; + let (elem, elem_ix) = Self::find_index_entry_mut(&mut self.index, key, self.random)?; let elem = if let Some(elem) = elem { elem } else { @@ -362,7 +362,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket { } pub fn delete_key(&mut self, key: &Pubkey) { - if let Some((elem, elem_ix)) = self.find_entry(key) { + if let Some((elem, elem_ix)) = self.find_index_entry(key) { if elem.num_slots > 0 { let ix = elem.data_bucket_ix() as usize; let data_bucket = &self.data[ix]; @@ -411,7 +411,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket { /* let dbg_elem: IndexEntry = *new_elem; assert_eq!( - Self::bucket_find_entry(&index, &elem.key, random).unwrap(), + Self::bucket_find_index_entry(&index, &elem.key, random).unwrap(), (&dbg_elem, new_ix) ); */ diff --git a/bucket_map/src/bucket_stats.rs b/bucket_map/src/bucket_stats.rs index e65672917..5940d3467 100644 --- a/bucket_map/src/bucket_stats.rs +++ b/bucket_map/src/bucket_stats.rs @@ -11,7 +11,7 @@ pub struct BucketStats { pub new_file_us: AtomicU64, pub flush_file_us: AtomicU64, pub mmap_us: AtomicU64, - pub find_entry_mut_us: AtomicU64, + pub find_index_entry_mut_us: AtomicU64, pub file_count: AtomicU64, pub total_file_size: AtomicU64, } diff --git a/runtime/src/bucket_map_holder_stats.rs b/runtime/src/bucket_map_holder_stats.rs index abbe208d4..eba225765 100644 --- a/runtime/src/bucket_map_holder_stats.rs +++ b/runtime/src/bucket_map_holder_stats.rs @@ -447,11 +447,11 @@ impl BucketMapHolderStats { i64 ), ( - "disk_index_find_entry_mut_us", + "disk_index_find_index_entry_mut_us", disk.map(|disk| disk .stats .index - .find_entry_mut_us + .find_index_entry_mut_us .swap(0, Ordering::Relaxed)) .unwrap_or_default(), i64