Skip to content

Do not allocate large Vec<PerInstructionCache> for each call frame. - #414

Open
seanyoung wants to merge 2 commits into
m1from
sean/fix
Open

Do not allocate large Vec<PerInstructionCache> for each call frame.#414
seanyoung wants to merge 2 commits into
m1from
sean/fix

Conversation

@seanyoung

@seanyoung seanyoung commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Description

By varying the generic type, nested calls can allocate a new per-instruction-cache per frame. Calls can be 1024 deep and a function can have 64K entries.

The per-instruction cache is sparse, as most instructions will not have an entry. A hash will have more cost for insert/get but this is O(1) and will be very fast. We add a benchmark which shows that the HashMap -> Vec makes no difference in performance.

Different fix for aptos-labs#20341

How Has This Been Tested?

See included bench mark and regular VM testing.

Key Areas to Review

  • Performance
  • Correctness

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Performance improvement
  • Refactoring
  • Dependency update
  • Documentation update
  • Tests

Which Components or Systems Does This Change Impact?

  • Validator Node
  • Full Node (API, Indexer, etc.)
  • Move/Aptos Virtual Machine
  • Aptos Framework
  • Aptos CLI/SDK
  • Developer Infrastructure
  • Move Compiler
  • Other (specify)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

By varying the generic type, nested calls can allocate a new
per-instruction-cache per frame. Calls can be 1024 deep and a function can have 64K entries.

The per-instruction cache is sparse, as most instructions will not have an entry. A hash will
have more cost for insert/get but this is O(1) and will be very fast. We add a benchmark
which shows that the HashMap -> Vec makes no difference in performance.
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.

1 participant