Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AccountsDb: make write_accounts_to_cache() never block sending to the bg hasher #3814

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ use {
u64_align, utils,
verify_accounts_hash_in_background::VerifyAccountsHashInBackground,
},
crossbeam_channel::{unbounded, Receiver, Sender},
crossbeam_channel::{unbounded, Receiver, Sender, TryRecvError},
dashmap::{DashMap, DashSet},
log::*,
rand::{thread_rng, Rng},
Expand Down Expand Up @@ -2344,7 +2344,7 @@ impl AccountsDb {
fn background_hasher(receiver: Receiver<Vec<CachedAccount>>) {
info!("Background account hasher has started");
loop {
let result = receiver.recv();
let result = receiver.try_recv();
match result {
Ok(accounts) => {
for account in accounts {
Expand All @@ -2355,7 +2355,10 @@ impl AccountsDb {
};
}
}
Err(err) => {
Err(TryRecvError::Empty) => {
sleep(Duration::from_millis(5));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the "right" sleep duration should be here, but 5 ms seems fine to start with.

}
Err(err @ TryRecvError::Disconnected) => {
info!("Background account hasher is stopping because: {err}");
break;
}
Expand Down
Loading