From e252cd6a2f69747e436b95d3ac77b4c36242942a Mon Sep 17 00:00:00 2001 From: Bjerg Date: Sat, 17 Jun 2023 03:05:09 +0200 Subject: [PATCH] fix: dynamic batch size for tx lookup stage (#3134) --- crates/stages/src/stages/tx_lookup.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/stages/src/stages/tx_lookup.rs b/crates/stages/src/stages/tx_lookup.rs index bf4b757cc3..5f3cd7056b 100644 --- a/crates/stages/src/stages/tx_lookup.rs +++ b/crates/stages/src/stages/tx_lookup.rs @@ -60,6 +60,7 @@ impl Stage for TransactionLookupStage { let (tx_range, block_range, is_final_range) = input.next_block_range_with_transaction_threshold(provider, self.commit_threshold)?; let end_block = *block_range.end(); + let tx_range_size = tx_range.clone().count(); debug!(target: "sync::stages::transaction_lookup", ?tx_range, "Updating transaction lookup"); @@ -67,7 +68,7 @@ impl Stage for TransactionLookupStage { let mut tx_cursor = tx.cursor_read::()?; let tx_walker = tx_cursor.walk_range(tx_range)?; - let chunk_size = 100_000 / rayon::current_num_threads(); + let chunk_size = (tx_range_size / rayon::current_num_threads()).max(1); let mut channels = Vec::with_capacity(chunk_size); let mut transaction_count = 0;