Skip to content

Thread compact Smi Shr successors - #91

Draft
chicoxyzzy wants to merge 1 commit into
mainfrom
perf/smi-shr-threading
Draft

Thread compact Smi Shr successors#91
chicoxyzzy wants to merge 1 commit into
mainfrom
perf/smi-shr-threading

Conversation

@chicoxyzzy

Copy link
Copy Markdown
Owner

Summary

  • Thread the measured LdaSmi8; Shr Int32 successor inside Lantern's existing merged Smi-load handler.
  • Preserve the ordinary Shr handler as the sole non-Int32 coercion, re-entry, BigInt, and exception path.
  • Keep bytecode and both JIT tiers unchanged while preserving logical opcode/pair/trigram telemetry.
  • Add adversarial fast/slow-path tests and record the telemetry, native-size, and A/B retention evidence.

Why

Crypto executes 4,646,114 LdaSmi8 -> Shr pairs (5.175% of its 89,774,038 logical instructions). A temporary eligibility probe found 4,645,838 Int32 hits and only 276 declines (99.994% eligible). Splay executes 2,084,482 compact Smi loads but no matching successors, so ordinary decode remains the hinted fallthrough.

Performance

  • 40+40 role-swapped arm64 compute-six: 0.9824x order-neutral geometric mean; every workload below 1.0x.
  • 60+60 targeted Crypto: 0.9484x; Splay, DeltaBlue, and arith_loop controls remained within the 2% gate.
  • Logical telemetry is identical after normalizing only direct-transfers; the counter rises by exactly 4,645,838.
  • Native cost: +52 bytes in runFrames, +48 bytes in Mach-O __TEXT.

The pinned x86_64 bench host was unreachable for three SSH attempts, so the retained wall-time evidence is explicitly role-swapped arm64. Local spreads make sub-percent controls directional; the targeted and compute-six Crypto estimates agree on the material win.

Validation

  • zig build test-fast
  • zig build test-fast -Dbytecode-stats=true -Dtest-filter='smi8 shr direct threading'
  • right-shift test262 baseline/candidate parity: 36 pass / 1 known fail, including candidate --gc-threshold=1
  • guarded non-cached full main test262: 48,653 pass / 1,324 known fail, no guard failure
  • zig fmt --check src/runtime/lantern/interpreter.zig src/runtime/lantern/tests.zig
  • git diff --check

Three independent final reviews covered runtime/GC/IP safety, test completeness, and benchmark arithmetic/provenance; all returned no actionable findings.

@chicoxyzzy

Copy link
Copy Markdown
Owner Author

Independent review summary

Three independent subagent reviews covered the published d342e53e diff:

  • Runtime / host safety: no findings. Bounds, IP advancement, noncommutative operand order, signed-shift semantics, non-Int32 fallback, JS re-entry/GC/exception behavior, logical stats, and unchanged JIT bytecode/deopt behavior are sound.
  • Tests: no findings. Coverage pins fast-path execution, exact telemetry, modulo-32 signed shifts, duplicate-execution avoidance, width/successor exclusions, Double/object/BigInt fallback, forced GC, and caught coercion throws.
  • Performance evidence / docs: no findings. All percentages, neutral ratios, geometric mean, targeted controls, transfer counts, native-size deltas, provenance, and noise caveats were independently recomputed.

CI is green 34/34, including both hosted unit suites, full conformance/RSS, Bistromath and Ohaimark differentials, every GC-stress partition, cross-builds, WASM spec tests, formatting, actionlint, and CodeQL.

The first standalone zig build wasm attempt hit the job's exact 15-minute ceiling with no compiler diagnostic; its isolated retry passed in 13m57s. Fifteen adjacent pre-PR runs put successful builds at 10m24s–13m55s (median ~12m53s, mean 12m33s, roughly one-minute standard deviation), and a prior exact-main run had the same timeout pattern. Review verdict: this is insufficient CI headroom, not a candidate-specific retention blocker. Keep the current native-proven source shape; raise that job's timeout to 20 minutes in a separate follow-up.

Verdict: no actionable findings.

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