Skip to content

Conversation

@MegaRedHand
Copy link
Collaborator

Motivation

static_left_pad appears in some flamegraphs, due to being used to encode bytecode metadata. This PR improves a bit the implementation.

Description

This PR removes some duplicate checks from the implementation, which might improve performance.

Copilot AI review requested due to automatic review settings November 12, 2025 20:35
@MegaRedHand MegaRedHand requested a review from a team as a code owner November 12, 2025 20:35
@github-actions github-actions bot added L1 Ethereum client performance Block execution throughput and performance in general labels Nov 12, 2025
@MegaRedHand MegaRedHand changed the title perf(l1): optimize static_left_pad perf(l1): remove duplicate checks n static_left_pad Nov 12, 2025
@MegaRedHand MegaRedHand changed the title perf(l1): remove duplicate checks n static_left_pad perf(l1): remove duplicate checks in static_left_pad Nov 12, 2025
Copilot finished reviewing on behalf of MegaRedHand November 12, 2025 20:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes the static_left_pad function used for encoding bytecode metadata by eliminating redundant bounds checking operations.

Key Changes:

  • Replaces explicit length check + saturating_sub + get_mut().ok_or() with a single checked_sub operation
  • Removes redundant bounds check by using direct indexing instead of get_mut()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

Lines of code report

Total lines added: 0
Total lines removed: 4
Total lines changed: 4

Detailed view
+------------------------------------+-------+------+
| File                               | Lines | Diff |
+------------------------------------+-------+------+
| ethrex/crates/common/rlp/decode.rs | 649   | -4   |
+------------------------------------+-------+------+

@MegaRedHand MegaRedHand moved this from Todo to In review in ethrex_performance Nov 25, 2025
@github-actions
Copy link

Benchmark Block Execution Results Comparison Against Main

Command Mean [s] Min [s] Max [s] Relative
base 60.714 ± 0.342 60.317 61.170 1.00
head 61.197 ± 0.660 60.539 62.823 1.01 ± 0.01

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

Labels

L1 Ethereum client performance Block execution throughput and performance in general

Projects

Status: No status
Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants