improvement: drop slow readers more quickly

This commit is contained in:
Greg Heartsfield 2023-02-01 18:09:30 -06:00
parent eb1d2d717d
commit 2b79099cfe
2 changed files with 5 additions and 5 deletions

View File

@ -364,9 +364,9 @@ impl NostrRepo for SqliteRepo {
if sql_gen_elapsed > Duration::from_millis(10) { if sql_gen_elapsed > Duration::from_millis(10) {
debug!("SQL (slow) generated in {:?}", filter_start.elapsed()); debug!("SQL (slow) generated in {:?}", filter_start.elapsed());
} }
// any client that doesn't cause us to generate new rows in 5 // any client that doesn't cause us to generate new rows in 2
// seconds gets dropped. // seconds gets dropped.
let abort_cutoff = Duration::from_secs(5); let abort_cutoff = Duration::from_secs(2);
let mut slow_first_event; let mut slow_first_event;
let mut last_successful_send = Instant::now(); let mut last_successful_send = Instant::now();
// execute the query. // execute the query.
@ -436,8 +436,8 @@ impl NostrRepo for SqliteRepo {
return Ok(()); return Ok(());
} }
// give the queue a chance to clear before trying again // give the queue a chance to clear before trying again
info!("query thread sleeping due to full query_tx (cid: {}, sub: {:?})", client_id, sub.id); debug!("query thread sleeping due to full query_tx (cid: {}, sub: {:?})", client_id, sub.id);
thread::sleep(Duration::from_millis(100)); thread::sleep(Duration::from_millis(500));
} }
// TODO: we could use try_send, but we'd have to juggle // TODO: we could use try_send, but we'd have to juggle
// getting the query result back as part of the error // getting the query result back as part of the error

View File

@ -576,7 +576,7 @@ async fn nostr_server(
// we will send out the tx handle to any query we generate. // we will send out the tx handle to any query we generate.
// this has capacity for some of the larger requests we see, which // this has capacity for some of the larger requests we see, which
// should allow the DB thread to release the handle earlier. // should allow the DB thread to release the handle earlier.
let (query_tx, mut query_rx) = mpsc::channel::<db::QueryResult>(20000); let (query_tx, mut query_rx) = mpsc::channel::<db::QueryResult>(20_000);
// Create channel for receiving NOTICEs // Create channel for receiving NOTICEs
let (notice_tx, mut notice_rx) = mpsc::channel::<Notice>(128); let (notice_tx, mut notice_rx) = mpsc::channel::<Notice>(128);