From ac9983f43e2fca7f10edd13ee07a3f39a9c61f6c Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 23 Feb 2024 10:46:07 -0800 Subject: [PATCH 1/5] Update the mempool capacity --- node/consensus/src/lib.rs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 30bc32c7e6..5b5a7970cb 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -53,10 +53,12 @@ use tokio::{ task::JoinHandle, }; -/// Percentage of mempool transactions capacity reserved for deployments. -const CAPACITY_FOR_DEPLOYMENTS: usize = 20; -/// Percentage of mempool transactions capacity reserved for executions. -const CAPACITY_FOR_EXECUTIONS: usize = 80; +/// The capacity of the mempool reserved for deployments. +const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 8; +/// The capacity of the mempool reserved for executions. +const CAPACITY_FOR_EXECUTIONS: usize = 1 << 10; +/// The capacity of the mempool reserved for solutions. +const CAPACITY_FOR_SOLUTIONS: usize = 1 << 10; /// Helper struct to track incoming transactions. struct TransactionsQueue { @@ -67,14 +69,8 @@ struct TransactionsQueue { impl Default for TransactionsQueue { fn default() -> Self { Self { - deployments: LruCache::new( - NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * CAPACITY_FOR_DEPLOYMENTS / 100) - .unwrap(), - ), - executions: LruCache::new( - NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * CAPACITY_FOR_EXECUTIONS / 100) - .unwrap(), - ), + deployments: LruCache::new(NonZeroUsize::new(CAPACITY_FOR_DEPLOYMENTS).unwrap()), + executions: LruCache::new(NonZeroUsize::new(CAPACITY_FOR_EXECUTIONS).unwrap()), } } } @@ -124,9 +120,7 @@ impl Consensus { ledger, bft, primary_sender: Default::default(), - solutions_queue: Arc::new(Mutex::new(LruCache::new( - NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH).unwrap(), - ))), + solutions_queue: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(CAPACITY_FOR_SOLUTIONS).unwrap()))), transactions_queue: Default::default(), seen_solutions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), seen_transactions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), From e99ad64ba2bae3c78b66750dd874f2e09d025646 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 27 Feb 2024 13:57:47 -0800 Subject: [PATCH 2/5] Tune values --- node/consensus/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 5b5a7970cb..574ed2eaf8 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -54,11 +54,13 @@ use tokio::{ }; /// The capacity of the mempool reserved for deployments. -const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 8; +const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 5; /// The capacity of the mempool reserved for executions. const CAPACITY_FOR_EXECUTIONS: usize = 1 << 10; /// The capacity of the mempool reserved for solutions. const CAPACITY_FOR_SOLUTIONS: usize = 1 << 10; +/// The maximum number of deployments the primary processes from the mempool at any given round. +const CAPACITY_FOR_DEPLOYMENT_VERIFICATION: usize = 1 << 3; /// Helper struct to track incoming transactions. struct TransactionsQueue { @@ -299,7 +301,7 @@ impl Consensus { // Acquire the lock on the transactions queue. let mut tx_queue = self.transactions_queue.lock(); // Determine the number of deployments to send. - let num_deployments = tx_queue.deployments.len().min(capacity * CAPACITY_FOR_DEPLOYMENTS / 100); + let num_deployments = tx_queue.deployments.len().min(CAPACITY_FOR_DEPLOYMENT_VERIFICATION); // Determine the number of executions to send. let num_executions = tx_queue.executions.len().min(capacity.saturating_sub(num_deployments)); // Create an iterator which will select interleaved deployments and executions within the capacity. From 3d8382370fdd4599ce689a01b26666f24bf4c62e Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 27 Feb 2024 14:10:48 -0800 Subject: [PATCH 3/5] Use a percentage for deployment verification --- node/consensus/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 574ed2eaf8..a725f37ab2 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -59,8 +59,8 @@ const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 5; const CAPACITY_FOR_EXECUTIONS: usize = 1 << 10; /// The capacity of the mempool reserved for solutions. const CAPACITY_FOR_SOLUTIONS: usize = 1 << 10; -/// The maximum number of deployments the primary processes from the mempool at any given round. -const CAPACITY_FOR_DEPLOYMENT_VERIFICATION: usize = 1 << 3; +/// The percentage of the transmissions being processed that are deployments. +const DEPLOYMENT_VERIFICATION_RATE: usize = 15; /// Helper struct to track incoming transactions. struct TransactionsQueue { @@ -301,7 +301,7 @@ impl Consensus { // Acquire the lock on the transactions queue. let mut tx_queue = self.transactions_queue.lock(); // Determine the number of deployments to send. - let num_deployments = tx_queue.deployments.len().min(CAPACITY_FOR_DEPLOYMENT_VERIFICATION); + let num_deployments = tx_queue.deployments.len().min(capacity * DEPLOYMENT_VERIFICATION_RATE / 100); // Determine the number of executions to send. let num_executions = tx_queue.executions.len().min(capacity.saturating_sub(num_deployments)); // Create an iterator which will select interleaved deployments and executions within the capacity. From 3b7269ee2bc18882cad758ff1fe33195fdb00387 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 3 Mar 2024 16:25:17 -0800 Subject: [PATCH 4/5] Adjust capacities --- node/consensus/src/lib.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 7aa1796837..5a3c6b3bd3 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -53,14 +53,18 @@ use tokio::{ task::JoinHandle, }; -/// The capacity of the mempool reserved for deployments. -const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 5; -/// The capacity of the mempool reserved for executions. +/// The capacity of the queue reserved for deployments. +/// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. +const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 4; +/// The capacity of the queue reserved for executions. +/// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. const CAPACITY_FOR_EXECUTIONS: usize = 1 << 10; -/// The capacity of the mempool reserved for solutions. +/// The capacity of the queue reserved for solutions. +/// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. const CAPACITY_FOR_SOLUTIONS: usize = 1 << 10; -/// The percentage of the transmissions being processed that are deployments. -const DEPLOYMENT_VERIFICATION_RATE: usize = 15; +/// The **suggested** maximum number of deployments in each interval. +/// Note: This is an inbound queue limit, not a Narwhal-enforced limit. +const MAX_DEPLOYMENTS_PER_INTERVAL: usize = 1; /// Helper struct to track incoming transactions. struct TransactionsQueue { @@ -301,7 +305,7 @@ impl Consensus { // Acquire the lock on the transactions queue. let mut tx_queue = self.transactions_queue.lock(); // Determine the number of deployments to send. - let num_deployments = tx_queue.deployments.len().min(capacity * DEPLOYMENT_VERIFICATION_RATE / 100); + let num_deployments = tx_queue.deployments.len().min(capacity).min(MAX_DEPLOYMENTS_PER_INTERVAL); // Determine the number of executions to send. let num_executions = tx_queue.executions.len().min(capacity.saturating_sub(num_deployments)); // Create an iterator which will select interleaved deployments and executions within the capacity. From 12cca3582d38bc5d7251a4f2753f2f8b69d471ba Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Tue, 12 Mar 2024 14:59:11 +0100 Subject: [PATCH 5/5] Increase CAPACITY_FOR_DEPLOYMENTS to 1 << 10 --- node/consensus/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 5a3c6b3bd3..a57d3bf6dc 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -55,7 +55,7 @@ use tokio::{ /// The capacity of the queue reserved for deployments. /// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. -const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 4; +const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 10; /// The capacity of the queue reserved for executions. /// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. const CAPACITY_FOR_EXECUTIONS: usize = 1 << 10;