perf(l1): avoid copy when reading account code#5289
Merged
Conversation
Lines of code reportTotal lines added: Detailed view |
MegaRedHand
approved these changes
Nov 12, 2025
Benchmark Block Execution Results Comparison Against Main
|
fmoletta
approved these changes
Nov 12, 2025
Oppen
reviewed
Nov 12, 2025
| let Some(bytes) = self | ||
| .db | ||
| .get_pinned_cf(&cf, code_hash.as_bytes()) | ||
| .map_err(|e| StoreError::Custom(format!("RocksDB read error: {}", e)))? |
Contributor
There was a problem hiding this comment.
Nit: is there no StoreError::ReadError or similar already?
Contributor
Author
There was a problem hiding this comment.
There is a ReadError but it's error message is "Could not open DB for reading" which implies a different kind of error, and doesn't pass-through the message.
Oppen
approved these changes
Nov 12, 2025
tomip01
pushed a commit
that referenced
this pull request
Nov 12, 2025
**Motivation** Currently we use `get_cf` for reading codes, which internally calls `get_pinned_cf` and copies the result. This copying takes up 6% of code reading time. **Description** Since data needs to be deserialized first, we could use a borrowed value and avoid this copy by calling `get_pinned_cf` directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Currently we use
get_cffor reading codes, which internally callsget_pinned_cfand copies the result. This copying takes up 6% of code reading time.Description
Since data needs to be deserialized first, we could use a borrowed value and avoid this copy by calling
get_pinned_cfdirectly.