Skip to content

Commit

Permalink
Status cache improvements (solana-labs#16174)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakridge authored Mar 29, 2021
1 parent 27ab415 commit 5e5b637
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 128 deletions.
4 changes: 2 additions & 2 deletions runtime/benches/status_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use solana_sdk::{
};
use test::Bencher;

type BankStatusCache = StatusCache<()>;
type BankStatusCache = StatusCache<Signature, ()>;

#[bench]
fn test_statuscache_serialize(bencher: &mut Bencher) {
let mut status_cache = BankStatusCache::default();
status_cache.add_root(0);
status_cache.clear_signatures();
status_cache.clear();
for hash_index in 0..100 {
let blockhash = Hash::new(&vec![hash_index; std::mem::size_of::<Hash>()]);
let mut id = blockhash;
Expand Down
12 changes: 6 additions & 6 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl ExecuteTimings {
}
}

type BankStatusCache = StatusCache<Result<()>>;
type BankStatusCache = StatusCache<Signature, Result<()>>;
#[frozen_abi(digest = "EcB9J7sm37t1R47vLcvGuNeiRciB4Efq1EDWDWL6Bp5h")]
pub type BankSlotDelta = SlotDelta<Result<()>>;
type TransactionAccountRefCells = Vec<Rc<RefCell<AccountSharedData>>>;
Expand Down Expand Up @@ -2328,15 +2328,15 @@ impl Bank {

/// Forget all signatures. Useful for benchmarking.
pub fn clear_signatures(&self) {
self.src.status_cache.write().unwrap().clear_signatures();
self.src.status_cache.write().unwrap().clear();
}

pub fn clear_slot_signatures(&self, slot: Slot) {
self.src
.status_cache
.write()
.unwrap()
.clear_slot_signatures(slot);
.clear_slot_entries(slot);
}

pub fn can_commit(result: &Result<()>) -> bool {
Expand Down Expand Up @@ -2546,7 +2546,7 @@ impl Bank {
let (lock_res, _nonce_rollback) = &lock_res;
if lock_res.is_ok()
&& rcache
.get_signature_status(
.get_status(
&tx.signatures[0],
&tx.message().recent_blockhash,
&self.ancestors,
Expand Down Expand Up @@ -4191,13 +4191,13 @@ impl Bank {
) -> Option<Result<()>> {
let rcache = self.src.status_cache.read().unwrap();
rcache
.get_signature_status(signature, blockhash, &self.ancestors)
.get_status(signature, blockhash, &self.ancestors)
.map(|v| v.1)
}

pub fn get_signature_status_slot(&self, signature: &Signature) -> Option<(Slot, Result<()>)> {
let rcache = self.src.status_cache.read().unwrap();
rcache.get_signature_slot(signature, &self.ancestors)
rcache.get_status_any_blockhash(signature, &self.ancestors)
}

pub fn get_signature_status(&self, signature: &Signature) -> Option<Result<()>> {
Expand Down
Loading

0 comments on commit 5e5b637

Please sign in to comment.