Skip to content

Conversation

@laurenthuberdeau
Copy link
Contributor

@laurenthuberdeau laurenthuberdeau commented Oct 3, 2025

Context

On the 20425 contracts executed at least 5 times between block 15M to ~19M, around 9365 have only direct jumps. Other contracts have a mix of direct and indirect jumps. For the contracts with only direct jumps, the jump table occupies around 5% of the total compiled code size (see table below showing the jump table size over the total code size), which can be removed since it will never be used.

 avg_jt | p10_jt | p50_jt | p90_jt | p99_jt 
--------+--------+--------+--------+--------
    4.9 |    3.8 |    4.5 |    5.6 |    7.4
(1 row)

Copilot AI review requested due to automatic review settings October 3, 2025 15:59
Copy link

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 compiled contract size by only generating jump tables when contracts contain indirect jumps. Based on analysis of ~20k contracts, approximately 46% contain only direct jumps, and for those contracts the jump table represents ~5% of compiled code size that can be eliminated.

  • Changed jump table label from required to optional using std::optional<asmjit::Label>
  • Added lazy initialization of jump table label only when first indirect jump is encountered
  • Wrapped jump table generation code with conditional check to skip emission when no indirect jumps exist

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
category/vm/compiler/ir/x86/emitter.hpp Changed jump_table_label_ member from asmjit::Label to std::optionalasmjit::Label
category/vm/compiler/ir/x86/emitter.cpp Updated initialization, added conditional jump table generation, and lazy label creation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@laurenthuberdeau laurenthuberdeau force-pushed the laurent/optimize-jumptable-size branch from fa8cf25 to 9f7eaa8 Compare October 10, 2025 14:15
@Baltoli Baltoli force-pushed the laurent/optimize-jumptable-size branch from 9f7eaa8 to cf502ca Compare October 17, 2025 08:54
@Baltoli Baltoli force-pushed the laurent/optimize-jumptable-size branch from cf502ca to c92b075 Compare October 17, 2025 10:06
@laurenthuberdeau laurenthuberdeau merged commit 5894b44 into main Oct 17, 2025
13 checks passed
@Baltoli Baltoli deleted the laurent/optimize-jumptable-size branch October 17, 2025 13:46
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.

4 participants