Skip to content

perf: optimize heap opcode paths#37

Merged
siyul-park merged 2 commits into
mainfrom
codex/heap-opcode-performance
May 22, 2026
Merged

perf: optimize heap opcode paths#37
siyul-park merged 2 commits into
mainfrom
codex/heap-opcode-performance

Conversation

@siyul-park

Copy link
Copy Markdown
Owner

Summary

  • Split interpreter allocation into fast no-root allocation and rooted public allocation paths.
  • Move map storage behind typed public methods with constructor-initialized metadata on MapType.
  • Inline small struct storage and fast-path native struct/string/array/map opcode handlers.
  • Remove types.Fielded; struct opcodes now handle native *types.Struct directly and fall back to concrete HostObject handling.

Impact

Heap-heavy interpreter opcodes for strings, arrays, structs, and maps avoid extra rooting, interface dispatch, and generic map handling on common hot paths. MapType metadata is now public cached state populated by constructors.

Validation

  • go test ./types ./interp
  • go test ./...
  • go test -race ./interp ./types
  • make lint
  • git diff --check
  • go test -run '^$' -bench 'BenchmarkInterpreter_Run/default/.*(string|array|struct|map)' -benchmem -benchtime=300ms ./interp

@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.67196% with 160 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.01%. Comparing base (52c6eda) to head (6c7ee75).

Files with missing lines Patch % Lines
interp/threaded.go 42.92% 88 Missing and 37 partials ⚠️
interp/marshal.go 48.14% 12 Missing and 2 partials ⚠️
types/map.go 87.15% 12 Missing and 2 partials ⚠️
interp/interp.go 68.75% 3 Missing and 2 partials ⚠️
interp/host.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #37      +/-   ##
==========================================
+ Coverage   53.84%   54.01%   +0.17%     
==========================================
  Files          58       57       -1     
  Lines        9867    10067     +200     
==========================================
+ Hits         5313     5438     +125     
- Misses       3930     3978      +48     
- Partials      624      651      +27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@siyul-park siyul-park changed the title [codex] optimize heap opcode paths perf: optimize heap opcode paths May 22, 2026
@siyul-park siyul-park marked this pull request as ready for review May 22, 2026 12:42
@siyul-park siyul-park merged commit a4762f8 into main May 22, 2026
5 checks passed
@siyul-park siyul-park deleted the codex/heap-opcode-performance branch May 22, 2026 23:18
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