forked from kaspanet/rusty-kaspa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "last known good" cache for virtual state (kaspanet#399)
* make a better estimation of header count (during IBD this will now count for the headers phase) * rpc service responsiveness: use `transaction_count_sample` for inferring mempool size * use counters snapshot * introduce last known good virtual state cache * move processing counters to consensus core and remove rpc service crate dep on consensus * extract consensus stats to a single call * turn some consensus session calls into non-async + fix get_block_dag_info_call * use saturating_sub instead of checked_sub + unwrap_or_default * use join over all async calls --------- Co-authored-by: coderofstuff <114628839+coderofstuff@users.noreply.github.com> --------- Co-authored-by: coderofstuff <114628839+coderofstuff@users.noreply.github.com>
- Loading branch information
1 parent
d4ddaf3
commit 401aa16
Showing
21 changed files
with
295 additions
and
148 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use std::sync::atomic::{AtomicU64, Ordering}; | ||
|
||
#[derive(Default)] | ||
pub struct ProcessingCounters { | ||
pub blocks_submitted: AtomicU64, | ||
pub header_counts: AtomicU64, | ||
pub dep_counts: AtomicU64, | ||
pub mergeset_counts: AtomicU64, | ||
pub body_counts: AtomicU64, | ||
pub txs_counts: AtomicU64, | ||
pub chain_block_counts: AtomicU64, | ||
pub mass_counts: AtomicU64, | ||
} | ||
|
||
impl ProcessingCounters { | ||
pub fn snapshot(&self) -> ProcessingCountersSnapshot { | ||
ProcessingCountersSnapshot { | ||
blocks_submitted: self.blocks_submitted.load(Ordering::Relaxed), | ||
header_counts: self.header_counts.load(Ordering::Relaxed), | ||
dep_counts: self.dep_counts.load(Ordering::Relaxed), | ||
mergeset_counts: self.mergeset_counts.load(Ordering::Relaxed), | ||
body_counts: self.body_counts.load(Ordering::Relaxed), | ||
txs_counts: self.txs_counts.load(Ordering::Relaxed), | ||
chain_block_counts: self.chain_block_counts.load(Ordering::Relaxed), | ||
mass_counts: self.mass_counts.load(Ordering::Relaxed), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq)] | ||
pub struct ProcessingCountersSnapshot { | ||
pub blocks_submitted: u64, | ||
pub header_counts: u64, | ||
pub dep_counts: u64, | ||
pub mergeset_counts: u64, | ||
pub body_counts: u64, | ||
pub txs_counts: u64, | ||
pub chain_block_counts: u64, | ||
pub mass_counts: u64, | ||
} | ||
|
||
impl core::ops::Sub for &ProcessingCountersSnapshot { | ||
type Output = ProcessingCountersSnapshot; | ||
|
||
fn sub(self, rhs: Self) -> Self::Output { | ||
Self::Output { | ||
blocks_submitted: self.blocks_submitted.saturating_sub(rhs.blocks_submitted), | ||
header_counts: self.header_counts.saturating_sub(rhs.header_counts), | ||
dep_counts: self.dep_counts.saturating_sub(rhs.dep_counts), | ||
mergeset_counts: self.mergeset_counts.saturating_sub(rhs.mergeset_counts), | ||
body_counts: self.body_counts.saturating_sub(rhs.body_counts), | ||
txs_counts: self.txs_counts.saturating_sub(rhs.txs_counts), | ||
chain_block_counts: self.chain_block_counts.saturating_sub(rhs.chain_block_counts), | ||
mass_counts: self.mass_counts.saturating_sub(rhs.mass_counts), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.