-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* scans crds table in parallel for finding old labels (#13073) From runtime profiles, the majority time of ClusterInfo::handle_purge https://github.com/solana-labs/solana/blob/0776fa05c/core/src/cluster_info.rs#L1605-L1626 is spent scanning crds table finding old labels: https://github.com/solana-labs/solana/blob/0776fa05c/core/src/crds.rs#L175-L197 This can be done in parallel given that gossip thread-pool: https://github.com/solana-labs/solana/blob/0776fa05c/core/src/cluster_info.rs#L1637-L1641 is idle when handle_purge is invoked: https://github.com/solana-labs/solana/blob/0776fa05c/core/src/cluster_info.rs#L1681 (cherry picked from commit 37c8842) # Conflicts: # core/tests/crds_gossip.rs * resolves mergify merge conflict Co-authored-by: behzad nouri <behzadnouri@gmail.com>
- Loading branch information
1 parent
6a4f89b
commit 428cacf
Showing
7 changed files
with
142 additions
and
63 deletions.
There are no files selected for viewing
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,31 @@ | ||
#![feature(test)] | ||
|
||
extern crate test; | ||
|
||
use rand::{thread_rng, Rng}; | ||
use rayon::ThreadPoolBuilder; | ||
use solana_core::crds::Crds; | ||
use solana_core::crds_gossip_pull::CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS; | ||
use solana_core::crds_value::CrdsValue; | ||
use solana_sdk::pubkey::Pubkey; | ||
use std::collections::HashMap; | ||
use test::Bencher; | ||
|
||
#[bench] | ||
fn bench_find_old_labels(bencher: &mut Bencher) { | ||
let thread_pool = ThreadPoolBuilder::new().build().unwrap(); | ||
let mut rng = thread_rng(); | ||
let mut crds = Crds::default(); | ||
let now = CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS + CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS / 1000; | ||
std::iter::repeat_with(|| (CrdsValue::new_rand(&mut rng), rng.gen_range(0, now))) | ||
.take(50_000) | ||
.for_each(|(v, ts)| assert!(crds.insert(v, ts).is_ok())); | ||
let mut timeouts = HashMap::new(); | ||
timeouts.insert(Pubkey::default(), CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS); | ||
bencher.iter(|| { | ||
let out = crds.find_old_labels(&thread_pool, now, &timeouts); | ||
assert!(out.len() > 10); | ||
assert!(out.len() < 250); | ||
out | ||
}); | ||
} |
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