Skip to content

Commit

Permalink
stat for time spent copying generate index contents
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington committed Sep 8, 2023
1 parent b588beb commit a02f41e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions accounts-db/src/bucket_map_holder_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub struct BucketMapHolderStats {
bins: u64,
pub estimate_mem: AtomicU64,
pub flush_should_evict_us: AtomicU64,
pub copy_us: AtomicU64,
}

impl BucketMapHolderStats {
Expand Down Expand Up @@ -516,6 +517,7 @@ impl BucketMapHolderStats {
.swap(0, Ordering::Relaxed),
i64
),
("copy_us", self.copy_us.swap(0, Ordering::Relaxed), i64),
);
} else {
datapoint_info!(
Expand Down
6 changes: 4 additions & 2 deletions accounts-db/src/in_mem_accounts_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,11 +677,13 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> InMemAccountsIndex<T,
assert!(self.bucket.is_some());

let mut insert = self.startup_info.insert.lock().unwrap();
// todo: memcpy the new slice into our vector already
// todo: avoid reallocs and just allocate another vec instead of likely resizing this one over and over
let m = Measure::start("copy");
items
.into_iter()
.for_each(|(k, (slot, v))| insert.push((k, (slot, v.into()))));
self.stats()
.copy_us
.fetch_add(m.end_as_us(), Ordering::Relaxed);
}

pub fn insert_new_entry_if_missing_with_lock(
Expand Down

0 comments on commit a02f41e

Please sign in to comment.