Skip to content

perf: remove unnecessary clone in transaction execution loop#103

Closed
KENILSHAHH wants to merge 0 commit intomegaeth-labs:mainfrom
KENILSHAHH:main
Closed

perf: remove unnecessary clone in transaction execution loop#103
KENILSHAHH wants to merge 0 commit intomegaeth-labs:mainfrom
KENILSHAHH:main

Conversation

@KENILSHAHH
Copy link

Summary

execute_transactions previously called tx.inner.clone().into_inner() on every
transaction to obtain an owned T, solely to take a reference &T from it.
This resulted in a heap allocation and full copy of the transaction data on every
iteration of the hot execution loop, with the allocation being immediately discarded
at the end of each loop body.

The fix replaces this with tx.inner.inner.as_recovered_ref(), which converts
&Recovered<T> to Recovered<&T> in-place by wrapping a pointer to the existing
data.
No allocation or copy is performed.

The T: Clone bound on execute_transactions is also removed, as it existed
solely to support the now-removed clone.

Note: The tracing executor (tracing_executor.rs) already accessed transaction
data without cloning — this change brings execute_transactions in line with that
existing pattern.

@KENILSHAHH KENILSHAHH requested a review from flyq as a code owner March 23, 2026 18:39
@KENILSHAHH KENILSHAHH changed the title Optimize transaction execution by removing unnecessary clone perf: remove unnecessary clone in transaction execution loop Mar 23, 2026
Copy link
Member

@flyq flyq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job!

@KENILSHAHH
Copy link
Author

adding some more changes through another branch @flyq

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.

2 participants