Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Status cache improvements (#16174) (#16511)
Browse files Browse the repository at this point in the history
Co-authored-by: sakridge <sakridge@gmail.com>
  • Loading branch information
mergify[bot] and sakridge authored Apr 13, 2021
1 parent a6b346d commit 0d3756b
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 @@ -111,7 +111,7 @@ impl ExecuteTimings {
}
}

type BankStatusCache = StatusCache<Result<()>>;
type BankStatusCache = StatusCache<Signature, Result<()>>;
#[frozen_abi(digest = "3ZaEt781qwhfQSE4DZPBHhng2S6MuimchRjkR9ZWzDFs")]
pub type BankSlotDelta = SlotDelta<Result<()>>;
type TransactionAccountRefCells = Vec<Rc<RefCell<Account>>>;
Expand Down Expand Up @@ -2329,15 +2329,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 @@ -2544,7 +2544,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 @@ -4142,13 +4142,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 0d3756b

Please sign in to comment.