AcctIdx: set age of cache accesses to future (#20125)

This commit is contained in:
Jeff Washington (jwash) 2021-09-23 11:43:48 -05:00 committed by GitHub
parent fb55e9a9b6
commit 5dae615208
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -142,7 +142,8 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
Self::update_time_stat(time, m);
Self::update_stat(count, 1);
if result.is_some() {
if let Some(entry) = result.as_ref() {
entry.set_age(self.storage.future_age_to_flush());
return result;
}
@ -258,6 +259,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
reclaims,
previous_slot_entry_was_cached,
);
current.set_age(self.storage.future_age_to_flush());
Self::update_stat(&self.stats().updates_in_mem, 1);
}
Entry::Vacant(vacant) => {
@ -536,11 +538,13 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
if let Some(disk) = self.storage.disk.as_ref() {
let items = disk.items_in_range(self.bin, range);
let mut map = self.map().write().unwrap();
let future_age = self.storage.future_age_to_flush();
for item in items {
let entry = map.entry(item.pubkey);
match entry {
Entry::Occupied(_occupied) => {
// do nothing - item already in cache
Entry::Occupied(occupied) => {
// item already in cache, bump age to future. This helps the current age flush to succeed.
occupied.get().set_age(future_age);
}
Entry::Vacant(vacant) => {
vacant.insert(self.disk_to_cache_entry(item.slot_list, item.ref_count));