optimize get_accounts_delta_hash (#21027)
This commit is contained in:
committed by
GitHub
parent
e9ab214237
commit
7a41b2c5d1
@ -5828,25 +5828,16 @@ impl AccountsDb {
|
|||||||
if self.is_filler_account(loaded_account.pubkey()) {
|
if self.is_filler_account(loaded_account.pubkey()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let should_insert =
|
// keep the latest write version for each pubkey
|
||||||
if let Some(existing_entry) = accum.get(loaded_account.pubkey()) {
|
match accum.entry(*loaded_account.pubkey()) {
|
||||||
loaded_write_version > existing_entry.value().version()
|
Occupied(mut occupied_entry) => {
|
||||||
} else {
|
if loaded_write_version > occupied_entry.get().version() {
|
||||||
true
|
occupied_entry.insert((loaded_write_version, loaded_hash));
|
||||||
};
|
|
||||||
if should_insert {
|
|
||||||
// Detected insertion is necessary, grabs the write lock to commit the write,
|
|
||||||
match accum.entry(*loaded_account.pubkey()) {
|
|
||||||
// Double check in case another thread interleaved a write between the read + write.
|
|
||||||
Occupied(mut occupied_entry) => {
|
|
||||||
if loaded_write_version > occupied_entry.get().version() {
|
|
||||||
occupied_entry.insert((loaded_write_version, loaded_hash));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Vacant(vacant_entry) => {
|
Vacant(vacant_entry) => {
|
||||||
vacant_entry.insert((loaded_write_version, loaded_hash));
|
vacant_entry.insert((loaded_write_version, loaded_hash));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user