@@ 1,5 1,5 @@
#!/usr/bin/env tarantool
--- Trace-stability gate (PLAN.md M6).
+-- Trace-stability gate for protobuf encode/decode hot paths.
--
-- For each hot encode/decode path, run a few thousand iterations with
-- a `trace` listener attached and assert that no trace aborts in
@@ 30,6 30,15 @@ package.path = './runtime/?.lua;./runtime/?/init.lua;'
.. package.path
jit.on()
+-- macOS arm64 mcode arena hardening: the default sizemcode/maxmcode are too
+-- small for our combined hot-path codegen footprint, and the allocator
+-- intermittently fails to find an executable page within the signed-32-bit
+-- offset window. When that happens the gate reports every check as
+-- 'stops=0' with no diagnostic — indistinguishable from a real JIT
+-- topology regression. Raising the arena past our peak need eliminates
+-- the failure mode and keeps the gate's pass/fail signal load-bearing.
+jit.opt.start('sizemcode=64', 'maxmcode=4096')
+
local vmdef = require('jit.vmdef')
-- Codes from jit.vmdef.traceerr (1-indexed). We treat these as fatal —
@@ 94,6 103,16 @@ local function record(fn, warmup_iters, measured_iters)
end
end
end
+ -- Defensive: keep the listener out of the JIT. If the callback ever
+ -- becomes hot enough to be traced, recording the cb while recording
+ -- the function-under-test races and stop events are dropped (starts
+ -- still fire, but most traces never finish recording). The current
+ -- cb body branches enough to dodge this organically, but any future
+ -- extension (per-event timing, pc context capture, etc.) would
+ -- re-trigger it silently. Reproducible in a few lines: a fat cb
+ -- that appends event tuples to a table drops Person_encode's stop
+ -- count from ~9 to 0 on this codebase.
+ jit.off(cb)
jit.attach(cb, 'trace')
for _ = 1, measured_iters do fn() end
jit.attach(cb)