small refactor to shorten the lock on slot_under_contention hashset (#23891)
* small refactor to shorten the lock on slot_under_contention hashset * adding comments * comments
This commit is contained in:
parent
91c2729856
commit
90009f330b
|
@ -4853,22 +4853,14 @@ impl AccountsDb {
|
||||||
slot: Slot,
|
slot: Slot,
|
||||||
should_flush_f: Option<&mut impl FnMut(&Pubkey, &AccountSharedData) -> bool>,
|
should_flush_f: Option<&mut impl FnMut(&Pubkey, &AccountSharedData) -> bool>,
|
||||||
) -> Option<FlushStats> {
|
) -> Option<FlushStats> {
|
||||||
let is_being_purged = {
|
if self
|
||||||
let mut slots_under_contention = self
|
.remove_unrooted_slots_synchronization
|
||||||
.remove_unrooted_slots_synchronization
|
.slots_under_contention
|
||||||
.slots_under_contention
|
.lock()
|
||||||
.lock()
|
.unwrap()
|
||||||
.unwrap();
|
.insert(slot)
|
||||||
// If we're purging this slot, don't flush it here
|
{
|
||||||
if slots_under_contention.contains(&slot) {
|
// We have not see this slot, flush it.
|
||||||
true
|
|
||||||
} else {
|
|
||||||
slots_under_contention.insert(slot);
|
|
||||||
false
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if !is_being_purged {
|
|
||||||
let flush_stats = self.accounts_cache.slot_cache(slot).map(|slot_cache| {
|
let flush_stats = self.accounts_cache.slot_cache(slot).map(|slot_cache| {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
{
|
{
|
||||||
|
@ -4898,6 +4890,7 @@ impl AccountsDb {
|
||||||
.notify_all();
|
.notify_all();
|
||||||
flush_stats
|
flush_stats
|
||||||
} else {
|
} else {
|
||||||
|
// We have already seen this slot. It is already under flushing. Skip.
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue