Skip to content

perf(vm): optimize cached JUMPDEST analysis - #7067

Open
yanghang8612 wants to merge 2 commits into
tronprotocol:release_v4.8.3from
yanghang8612:opt/jumpdest-cache
Open

yanghang8612 wants to merge 2 commits into
tronprotocol:release_v4.8.3from
yanghang8612:opt/jumpdest-cache

Conversation

@yanghang8612

Copy link
Copy Markdown
Collaborator

What does this PR do?

Optimize each cached JUMPDEST analysis by storing positions in a bitmap instead of a HashSet of program counters. The scan is unchanged: a JUMPDEST opcode is recorded, and the immediate bytes of PUSH1 through PUSH32 are still skipped. A program counter outside the code returns false.

The cache key, the entry cap, and energy charging stay the same. A constant call still compiles on the frame and is not inserted into the cache.

Why are these changes required?

Each cached analysis kept one boxed integer per JUMPDEST. The bitmap records the same positions and substantially reduces the space occupied by the cache.

This PR has been tested by:

  • Unit Tests

JumpDestBitmapTest checks the bitmap against the previous scan, including PUSH immediate data, a single destination among other bytes, and random code.

Follow up

A failed CREATE analysis is still inserted into the cache. This change does not remove those entries.

Extra details

A finished analysis reports the same JUMPDEST positions as before, so this does not require a proposal gate.

@halibobo1205 halibobo1205 added this to the GreatVoyage-v4.8.3 milestone Oct 27, 2026
@halibobo1205 halibobo1205 added the topic:vm VM, smart contract label Oct 27, 2026
Replace the HashSet of program counters. Cache key, size, and
admission stay the same.
@alan-eth

Copy link
Copy Markdown

The bitmap is a compact way to preserve the existing JUMPDEST lookup behavior. Would it be worth adding lightweight cache hit/miss counters in Program.getProgramPrecompile() to help assess cache effectiveness under real workloads? We could count only actual shared-cache lookups, keeping constant calls separate since they bypass the LRU. This could also be a follow-up to keep this optimization focused.

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

Labels

topic:vm VM, smart contract

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants