From a5be445ef9438d3aa6a4b8b4365d3827c5b97402 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 11 Sep 2024 13:20:25 +0200 Subject: [PATCH] chore: lower persistence threshold (#10833) --- crates/engine/tree/src/tree/config.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/engine/tree/src/tree/config.rs b/crates/engine/tree/src/tree/config.rs index 600fb62b6..9d93660c8 100644 --- a/crates/engine/tree/src/tree/config.rs +++ b/crates/engine/tree/src/tree/config.rs @@ -1,7 +1,11 @@ //! Engine tree configuration. -const DEFAULT_PERSISTENCE_THRESHOLD: u64 = 6; -const DEFAULT_MEMORY_BLOCK_BUFFER_TARGET: u64 = 6; +/// Triggers persistence when the number of canonical blocks in memory exceeds this threshold. +const DEFAULT_PERSISTENCE_THRESHOLD: u64 = 2; + +/// How close to the canonical head we persist blocks. +const DEFAULT_MEMORY_BLOCK_BUFFER_TARGET: u64 = 2; + const DEFAULT_BLOCK_BUFFER_LIMIT: u32 = 256; const DEFAULT_MAX_INVALID_HEADER_CACHE_LENGTH: u32 = 256; @@ -15,6 +19,8 @@ pub struct TreeConfig { persistence_threshold: u64, /// How close to the canonical head we persist blocks. Represents the ideal /// number of most recent blocks to keep in memory for quick access and reorgs. + /// + /// Note: this should be less than or equal to `persistence_threshold`. memory_block_buffer_target: u64, /// Number of pending blocks that cannot be executed due to missing parent and /// are kept in cache. @@ -22,6 +28,9 @@ pub struct TreeConfig { /// Number of invalid headers to keep in cache. max_invalid_header_cache_length: u32, /// Maximum number of blocks to execute sequentially in a batch. + /// + /// This is used as a cutoff to prevent long-running sequential block execution when we receive + /// a batch of downloaded blocks. max_execute_block_batch_size: usize, }