ReviewOS

zig-utils/zig-js

Perf: batch exact JIT accounting across hot CFG successors

#55
Closed chris opened this 9 days ago ·
9 days ago

Problem

The numeric baseline tier now batches step-budget and 1,024-step safepoint accounting per basic block, but hot loop iterations still cross a conditional block and its single-predecessor fallthrough body. Each block pays the same compare/branch/subtract accounting prefix, leaving roughly seven redundant ARM64 instructions on the critical path per iteration.

Scope

  • Build predecessor metadata for the verified numeric CFG.
  • Form hot conditional-fallthrough superblocks only when the successor has one predecessor and no target can enter the middle.
  • Pre-account both blocks at the conditional entry.
  • Refund the successor length on the cold condition-false edge.
  • Preserve a separately guarded successor entry for slow replay and any non-hot transfer.
  • Keep exact max-step+1 errors and 1,024-step checkpoint timing.
  • Add focused branch/checkpoint/budget coverage and order-balanced direct arithmetic A/B evidence.
  • Do not replace the accepted symmetric JSC report until this joins a meaningful optimization batch.

Parent tracking: #52 Arithmetic target: #46

9 days ago

Completed in 8af9df8f (perf(jit): batch hot successor accounting (#55)) and pushed to main.

Implemented verified CFG predecessor counts, single-predecessor conditional fallthrough covering, guardless physical hot entries, separately guarded replay/transfer entries, and exact false-edge counter refunds.

Validation:

  • ReleaseFast direct compiler sweep passed at checkpoint distances 1 through 47 with identical result and exact total steps.
  • ReleaseFast VM numeric-tier test passed interpreter/native delta checks, non-number fallback, IEEE remainder cases, and exact max-step+1 RangeError.
  • Order-balanced direct arithmetic A/B against 02dc511a:
    • Official 80 jobs, 10 samples/binary: 340.866 ms candidate vs 342.946 ms parent median (1.0061x throughput), checksum 74,803,480.
    • Longer-signal 160 jobs, 6 samples/binary: 675.157 ms vs 678.785 ms median (1.0054x), checksum 149,613,360.

The accepted symmetric JSC publication remains unchanged until a larger optimization batch.

Sign in to comment on this issue.