Skip to content

Optimize method call performance with inline cache and setFromList fast path#285

Merged
fglock merged 2 commits into
masterfrom
fix-interpreter-pop-blocknode
Mar 7, 2026
Merged

Optimize method call performance with inline cache and setFromList fast path#285
fglock merged 2 commits into
masterfrom
fix-interpreter-pop-blocknode

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Mar 7, 2026

Summary

  • Add inline method cache in RuntimeCode.callCached() for monomorphic call sites
  • Add setFromList fast path for common my ($a, $b) = @_ pattern
  • Add RuntimeArray constructor with initial capacity to reduce ArrayList growth
  • Fix hasIsaChanged() to compare content instead of identity+size (fixes MRO regressions)
  • Fix setFromList fast path to copy RHS values before assignment (fixes aliasing in chained assignments)

Performance improvement: ~300/s → ~460-490/s (~55% faster)

Test plan

  • All 156 unit tests pass (7078/7078 assertions)
  • MRO tests back to baseline (mro/basic.t 53/66, mro/basic_utf8.t 42/53, etc.)
  • op/list.t back to baseline (71/75)
  • Chained assignment ($a,$b) = ($b,$a) = ($a,$b) works correctly
  • Recursive calls work correctly
  • Dynamic @isa changes invalidate cache properly

Generated with Devin

fglock and others added 2 commits March 7, 2026 21:51
…st path

- Add inline method cache in RuntimeCode.callCached() for monomorphic call sites
- Add setFromList fast path for common `my ($a, $b) = @_` pattern
- Add RuntimeArray constructor with initial capacity to reduce ArrayList growth
- Fix hasIsaChanged() to compare content instead of identity+size (fixes MRO regressions)
- Fix setFromList fast path to copy RHS values before assignment (fixes aliasing in chained assignments)

Performance improvement: ~300/s -> ~460-490/s (~55% faster)

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
Explain how monomorphic call site caching works for method dispatch optimization.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
@fglock fglock merged commit a407d66 into master Mar 7, 2026
2 checks passed
@fglock fglock deleted the fix-interpreter-pop-blocknode branch March 7, 2026 20:57
@fglock fglock restored the fix-interpreter-pop-blocknode branch March 9, 2026 06:59
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