What Was Done to Get Rid of Micro-Jerks
Investigation, telemetry instrumentation, and frame-pacing optimizations applied across the
120 Hz Sync Test harness and
Two-Features, Two-Handles (#debug)
on Spacesheep and GitHub Pages.
Sync Test Micro-Jerks
4 → 0
Under ±0.55 ms Chrome IPC noise (
MICRO-JERK → 120 HZ SYNC)Sync Test JS p95
1.4 ms → 0.2 ms
7× faster JS frame time (0.0 ms median)
#debug Velocity CV (Pan)
0.0628 → 0.0001
628× lower step variance under ±0.55 ms IPC noise
Euclidean 2222 (Canvas 2D)
4 drops → 0 drops
jsP95 4.9 ms → 1.6 ms; 14/14 checks pass in
test:120hz1. Reading the Captured Failure Signature
Your macOS desktop Chrome capture on 120hz-sync-test.html reported:
120.0101 Hz [GL|FIX] rDt 8.30/9.30 ph +/-0.60ms eo 0.00ms lag 0.1 js 0.20ms gpu 0.15ms · MICRO-JERK · DROP 0 · MICRO 16 · LATE 0 · GPU Query: ON
DPR 2 · q=0.1ms · COI=false
DPR 2 · q=0.1ms · COI=false
-
Zero real drops occurred:
DROP 0, OLS lock held at120.0101 Hz, even/odd cadence asymmetry waseo 0.00ms, and CPU/GPU costs were tiny (js 0.20ms,gpu 0.15ms). -
Differencing noise doubled IPC jitter: On macOS Chrome without Cross-Origin Isolation
(
COI=false, timer quantumq=0.1ms), normalCVDisplayLink → BeginMainFrameIPC delivery has bounded per-frame arrival jitter|ek| ≤ 0.60 ms(ph +/-0.60msrelative to the linear OLS VSYNC line). When adjacent noisy timestamps are differenced (rDtk = T + ek - ek-1), errors add up to±1.20 ms(plus0.1 mstimer quantization), causing clean frames to readrDt = 9.30 msand trip the original±1.0 msdetector. -
Driver query overhead when enabled: In the capture,
GPU Query: ONwas pollingEXT_disjoint_timer_query_webgl2(GPU_DISJOINT_EXT+ query availability) every frame.
2. What Was Fixed on 120hz-sync-test.html
-
Noise-floor calibration & OLS phase gating: Replaced the
±1.0 mssingle-interval threshold with calibrated thresholds above Chrome's doubled IPC noise floor:|rDt - T| > max(1.65, 0.20·T),|pDt - T| > max(2.0, 0.24·T),|phaseErr| > max(1.35, 0.16·T),lagDev > max(1.8, 0.22·T), and even/odd cadence asymmetryeoRafMs > 0.85 ms. Real 60 Hz beat (7.33/9.33 ms), phase slips (+2.4 ms), and dispatch lag spikes (+3.5 ms) are still caught immediately while normal±0.60 msIPC jitter reports zero false positives. -
Zero per-frame heap allocations in
tick(): Pre-allocated reusablelayout,olsOut,statusOut, andflipPatchRectCssstructs instead of allocating temporary objects every frame. -
Eliminated 5 per-frame insertion sorts: Cached
lagMedand parity medians (eoRafMs,eoPerfMs) once every 16 frames instead of sorting 5 ring slices every single 8.33 ms frame. -
Startup JIT/shader warmup: Extended post-init / post-reset warmup from 30 to 60 frames (0.5 s at 120 Hz) so initial ANGLE/Metal shader compilation does not trip a false
lateCommit/microJerk. -
Opaque WebGL2 pass without alpha blending: Disabled
gl.BLENDduring the opaque pre-blendedrectProgbatch (enabling blend only for textured HUD glyphs), reducing fragment bandwidth.
3. Micro-Jerk Telemetry & Optimizations Applied to two-features-two-handles#debug
-
OLS-locked integer-VSYNC step timing (
src/page.js): PreviouslydebugTick(rafTs)stepped bothpanandtwistusing jitteryperformance.now() - debugPrevTsintervals, turning IPC wakeup noise directly into velocity jitter. It now derivesnTicks = Math.round((rafTs - debugPrevRafTs) / T)using the OLS-locked periodT = debugMonitor.lockedPeriodMs()and advances by exactnTicks * T. -
Live micro-jerk & phase instrumentation (
src/perf-monitor.js,src/page.js): Added a zero-allocation 120-frame sliding OLS VSYNC regressor, even/odd parity interval tracking (eoRafMs,eoPerfMs), and calibratedmicroJerks+phaseSlipscounters surfaced in#dbg-stutters(0 stut · 0 micro · 0R/0L/0G),#dbg-jitter(ph/eo), fullscreen HUD,#dbg-graphHUD/amber bars, andwindow.__handles.debugSnapshot(). -
GPU: OFFby default (src/page.js,src/page.template.html): Removed unconditionalpattern.setGpuTiming(true, { sampleStride: 8 })on tab entry so Chromium is not forced to pollGPU_DISJOINT_EXT15 times per second unless the user explicitly togglesGPU: ON(sampleStride: 24). -
Zero-allocation O(1) history ring & throttled secondary canvas (
src/perf-monitor.js,src/page.css): Replaced per-framethis.history.shift()+ object allocation with a pre-allocated circular_histRing, throttled median updates (medLagMs,medRenderMs), addedcontain: stricton#dbg-graph, added aGraph: ON/OFFtoggle, and reduced graph redraw cadence to 4 Hz (Zero-DOM) / 8 Hz. -
WebGL2 hot path before Canvas-2D closures + cached
marksSet (src/pattern-ext.js): Movedgl.render(...)+ early return ahead of all 12 Canvas-2D path/projection closures on standard WebGL2 frames, and cachedmodel.marksSetandhasOnce/hasDotsflags insideapi.set()instead of rebuilding them on every frame. -
Euclidean 2D scroll path speedup (
src/pattern-ext.js): Inlined the 2D affine matrix transform insideprint()forkind === 'E'and deferred Catmull-Rom spline smoothing whilequick === trueduring active wheel motion (restoring splines once settled), eliminating all frame drops on the2222wheel check.
4. Verified Before & After Measurements
A. Simulated macOS Chrome ±0.55 ms IPC Jitter Harness (q=0.1 ms, bench-microjerks.mjs)
| Target & Metric | Before | After | Notes |
|---|---|---|---|
120hz-sync-test.html — Micro-jerks |
4 | 0 | False positives over ~312 frames |
120hz-sync-test.html — Late commits |
1 | 0 | Initial startup + threshold calibration |
120hz-sync-test.html — Status badge |
MICRO-JERK | 120 HZ SYNC | hardDrops=0, olsHz=119.9958 Hz |
120hz-sync-test.html — JS P50 / P95 |
0.1 ms / 1.4 ms | 0.0 ms / 0.2 ms | Zero per-frame allocs & 16-frame sort cache |
#debug (3333 Fast Pan) — Velocity CV |
0.0628 | 0.0001 | OLS-locked nTicks * T stepping |
#debug — Micro-jerk UI counter |
none (null) | 0 micro (GPU: OFF) |
Live in #dbg-stutters, graph HUD, & API |
B. Headless Chrome Virtual 120 Hz Metal Pacer Suite (npm run test:120hz)
| Scenario | Before | After | Status |
|---|---|---|---|
1. Debug Pan Fast (3333) |
cv=0.1014, drops=0, lr=0 | cv=0.005, micro=0, drops=0, jsP95=0.2ms, lr=0 | PASS |
5. Play 2222 Euclidean wheel (Canvas 2D) |
drops=4, dt=8.33/25.43ms, jsP95=4.9ms, cv=0.2558 | drops=0, dt=8.33/8.33ms, jsP95=1.6ms, cv=0.0601 | PASS |
120hz-sync-test.html fault & layout suite |
20 checks (baseline) | 21/21 passed (incl. Test 2b IPC noise = 0 micro-jerks) | PASS |
two-features-two-handles unit tests |
87/87 passed | 88/88 passed (incl. ±0.55 ms / beat / slip test) | PASS |