Skip to content

perf: dedicated transaction worker - #2685

Draft
carneiro-cw wants to merge 10 commits into
mainfrom
transaction_worker
Draft

perf: dedicated transaction worker#2685
carneiro-cw wants to merge 10 commits into
mainfrom
transaction_worker

Conversation

@carneiro-cw

@carneiro-cw carneiro-cw commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

PR Type

Enhancement, Tests


Description

  • Extend #[timed] macro with start/end/duration markers

  • Add TransactionWorker for serial transaction execution

  • Refactor Executor and EvmWorkerPool accordingly

  • Update metrics definitions and Semaphore metrics


File Walkthrough

Relevant files
Documentation
1 files
lib.rs
Expand timed macro docs with markers                                         
+32/-3   
Enhancement
7 files
timed_attribute.rs
Implement timing window support with markers                         
+355/-22
lib.rs
Export timed_start/end/duration macros                                     
+44/-0   
evm_worker_pool.rs
Remove transaction channel and adjust pools                           
+0/-10   
mod.rs
Refactor Executor to use TransactionWorker                             
+32/-97 
transaction_worker.rs
Add TransactionWorker for serial transactions                       
+215/-0 
task.rs
Remove Transaction variant from EvmRoute                                 
+0/-3     
utils.rs
Track permit holders in Semaphore metrics                               
+4/-0     
Configuration changes
1 files
definitions.rs
Rename semaphore-related gauge metrics                                     
+4/-4     
Tests
1 files
timed_attribute_tests.rs
Extend timed macro tests with marker cases                             
+89/-4   

@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Semaphore metrics inverted

In Semaphore::acquire, the code only calls dec_executor_local_transaction_semaphore_waiting
but never increments that waiting gauge before blocking. As a result the waiting gauge
can go negative and never reflects the actual number of tasks waiting.

#[cfg(feature = "metrics")]
metrics::dec_executor_local_transaction_semaphore_waiting(1);
#[cfg(feature = "metrics")]
metrics::inc_executor_local_transaction_permit_holders(1);
Permit { sem: Arc::clone(&self.sem) }
Duplicate metric description

The new executor_local_transaction_permit_holders gauge uses the same
description as the waiting gauge. It should describe the number of
current permit holders, not waiting transactions.

"Number of transactions waiting to acquire the local transaction warmup semaphore."
gauge executor_local_transaction_semaphore_waiting{},

"Number of transactions waiting to acquire the local transaction warmup semaphore."
gauge executor_local_transaction_permit_holders{},

@github-actions

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Correctly track semaphore waiters

The waiting gauge is never incremented when a task blocks on the semaphore. Add a
metrics::inc_executor_local_transaction_semaphore_waiting call before entering the
wait loop and move the decrement to immediately after acquiring the permit.

src/utils.rs [63-71]

 pub fn acquire(&self) -> Permit {
     let mut permits = self.permits.lock();
+    #[cfg(feature = "metrics")]
+    metrics::inc_executor_local_transaction_semaphore_waiting(1);
     while *permits == 0 {
         self.cvar.wait(&mut permits);
     }
+    #[cfg(feature = "metrics")]
+    metrics::dec_executor_local_transaction_semaphore_waiting(1);
     *permits -= 1;
     drop(permits);
-    #[cfg(feature = "metrics")]
-    metrics::dec_executor_local_transaction_semaphore_waiting(1);
     #[cfg(feature = "metrics")]
     metrics::inc_executor_local_transaction_permit_holders(1);
     Permit { sem: Arc::clone(&self.sem) }
 }
Suggestion importance[1-10]: 7

__

Why: Adding metrics::inc_executor_local_transaction_semaphore_waiting before the wait loop and moving the decrement right after acquiring the permit fixes the unbalanced gauge and ensures accurate metrics for blocked tasks.

Medium

@stratus-benchmark

Copy link
Copy Markdown

Forwarding benchmark:
Run ID: bench-5e4151d6

Git Info:

Follower Stats (transactions sent to follower):
RPS Stats: Max: 14023.00, Min: 72.00, Avg: 5677.27, StdDev: 1790.65
TPS Stats: Max: 8050.00, Min: 57.00, Avg: 4784.46, StdDev: 1263.85

Plots:

@stratus-benchmark

Copy link
Copy Markdown

Forwarding benchmark:
Run ID: bench-65f5a01e

Git Info:

Follower Stats (transactions sent to follower):
RPS Stats: Max: 12236.00, Min: 218.00, Avg: 5759.76, StdDev: 1766.51
TPS Stats: Max: 8271.00, Min: 63.00, Avg: 5002.46, StdDev: 1183.70

Plots:

@stratus-benchmark

Copy link
Copy Markdown

Forwarding benchmark:
Run ID: bench-94178729

Git Info:

Follower Stats (transactions sent to follower):
RPS Stats: Max: 14714.00, Min: 1.00, Avg: 5780.85, StdDev: 1854.78
TPS Stats: Max: 8146.00, Min: 113.00, Avg: 4906.89, StdDev: 1319.65

Plots:

@stratus-benchmark

Copy link
Copy Markdown

Forwarding benchmark:
Run ID: bench-cc6975dc

Git Info:

Follower Stats (transactions sent to follower):
RPS Stats: Max: 12913.00, Min: 1.00, Avg: 5246.68, StdDev: 2705.43
TPS Stats: Max: 6991.00, Min: 23.00, Avg: 3767.58, StdDev: 1941.44

Plots:

@stratus-benchmark

Copy link
Copy Markdown

Forwarding benchmark:
Run ID: bench-67764ef5

Git Info:

Follower Stats (transactions sent to follower):
RPS Stats: Max: 13972.00, Min: 272.00, Avg: 5301.52, StdDev: 898.61
TPS Stats: Max: 8398.00, Min: 65.00, Avg: 5215.16, StdDev: 680.21

Plots:

@stratus-benchmark

Copy link
Copy Markdown

Forwarding benchmark:
Run ID: bench-5d84617e

Git Info:

Follower Stats (transactions sent to follower):
RPS Stats: Max: 8680.00, Min: 2534.00, Avg: 5357.67, StdDev: 705.13
TPS Stats: Max: 8356.00, Min: 55.00, Avg: 5319.81, StdDev: 670.36

Plots:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant