Repository navigation
perf(jit): serve array.slice as a callout - #316
Merged
Merged
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
siyul-park
force-pushed
the
perf/jit-slice-callout
branch
from
November 10, 2026 00:52
86a7479 to
5ffc6a4
Compare
ARRAY_SLICE had no lowering, so each one bridged: a scratch frame, operand retains and a handler run. fannkuch bridged it 720 times per Run, 28% of its CPU. The op only allocates a copy, the class callouts serve: Go computes the object from the operand words and native code keeps ownership of the operands. The slice semantics move into Interpreter.slice, which the threaded handler and the callout both call (as concat is shared); share retains a ref array's elements after its allocation, so a heap-exhaustion panic leaves every count unchanged. A host view still deopts. Callout arguments widen to three. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
siyul-park
force-pushed
the
perf/jit-slice-callout
branch
from
November 10, 2026 04:03
4a0d914 to
6c09e1c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part C1 of the string/allocation review. pprof of fannkuch jit:
engine.settle47.6%, of whichengine.bridge27.8%, becauseARRAY_SLICEhas no lowering and bridges 720 times per Run. The op only allocates a copy, which is the class the callout path serves without a scratch frame, operand retains, or a handler run.Interpreter.slice(array, start, end)holds the semantics (type check, host-view conversion, range check, typedcut[T]ornewArray+ copy) and retains nothing. The generated threaded handler and the callout both call it, asconcatis shared.Interpreter.shareretains a ref array's elements afteralloc, so a heap-exhaustion panic leaves every count unchanged. This keeps the handler's existing order.callouts[ARRAY_SLICE]; the callout args widen from 2 to 3.ARRAY_SLICEadopts none (transform.Adoptsis 0), so native code keeps and releases the container, exactly once, as forSTRING_CONCAT.engine.bridge'shostedrule, so host conversion never runs under native code.jit-internals.mdCallout row.Evidence
TestWithThresholdnew subtest:Limitation:
vm_jit_exits_total{kind="bridge"}counts callouts too, since both areExitBridge, so no test pins callout vs bridge. This test is a parity guard, and the A/B below is the evidence of the change.Local A/B (6 × 300 ms): fannkuch about −7% (131.0 → 122.5 µs). sort-stress and permutation-flips are within noise; only fannkuch slices. The CI report decides.
make generate && make check-generated(the diff only replaces the inline body with calls),go test ./interp ./internal/...,make check,git diff --check: pass.🤖 Generated with Claude Code