ReviewOS

zig-utils/zig-js

Intl.DateTimeFormat: project resolved hourCycle from a native enum

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

Parent: #475 Depends on: #460

Problem

IntlDateTimeFormatData already stores every closed component/style name as a native enum whose resolvedOptions() projection reuses immutable String values. The effective hourCycle is the remaining closed four-value field stored in object-owned bytes and projected with Value.strAlloc on every call. The current DateTimeFormat construction row invokes resolvedOptions() but does not read or checksum hourCycle, so it cannot attribute or guard this change.

Scope

  • Add a benchmark-first fresh-result workload covering h11, h12, h23, h24, locale -u-hc- resolution, hour12 precedence, and no-hour omission; checksum property presence, exact value, key order, result freshness, Shape identity, and unchanged source formatter state.
  • Represent the resolved effective cycle as a closed native enum after all user-observable option reads and locale resolution complete.
  • Project the enum through immutable String values, remove only its redundant bytes from DateTimeFormat-owned storage, and preserve fresh ordinary resolvedOptions() result objects and exact property creation order.
  • Measure exact invocation-phase managed cells, backing allocations/bytes, execution attribution, wall/CPU/RSS, and stable checksum against the exact parent before retaining the change.
  • Preserve constructor publication rollback, formatter teardown, moving GC, shared no-GIL reads, and every calendar/numbering-system/time-zone ownership boundary.

No-workaround rules

  • No intern-table mutation, unbounded cache, locale/time-zone shortcut, omitted option/property, altered getter order, reused result object, generated-table edit, system ICU/JSC dependency, or claim derived from noisy timing.
  • No stacks, queues, jobs, Promise/microtask, Worker lifecycle, or Map/Set iterator implementation changes.

Acceptance

  • Benchmark-first parent evidence freezes all four hour cycles, extension/override/absence controls, fresh result identity, key order, Shape identity, exact checksum, and allocation replay.
  • Candidate removes the per-call hourCycle managed String allocation and redundant owned bytes with identical logical work, execution attribution, and checksum; unrelated locale/calendar/numberingSystem/timeZone allocations remain unchanged.
  • Option observation, hour12 precedence, locale extension resolution, omission without an hour field, result freshness, and property order remain exact under forced tree-walker and required bytecode execution.
  • Deterministic OOM at construction and projection boundaries, formatter teardown, moving GC/compaction, no-GIL/TSan shared reads, and allocation-accounting witnesses pass without leaks or partial publication.
  • Focused Intl/DateTimeFormat units, full units, exact relevant Test262 accounting, dependency/docs/benchmark validation, and guarded exact-parent evidence pass with zero semantic flips.
  • A conventional commit lands directly on main, cross-links #475 and #460, and records allocation deltas without promoting diagnostic wall time.
9 days ago

Benchmark-first audit update:

  • The new hour-cycle reflection row exposed the pre-existing pattern-state correctness bug now tracked in #773. zig-js correctly resolves h11/h12/h23/h24 and hour12 precedence but omits JSC's pattern-added dayPeriod: "short" for 12-hour records.
  • The row now accepts only the two audited exact 12-hour key shapes and hashes every key/value, so the divergence remains visible rather than normalized: at 100 jobs zig-js checksum is 705814248, system JSC checksum is 242469243.
  • The first full harness run exposed stale V26 pins; #774 repaired them in e305bba0, and the full gate now passes 58/58 matrix checks plus 18/18 harness validators.

The #772 runtime remains unchanged. Its frozen 100-job parent attribution is checksum 705814248, 739,204 managed-cell allocations, 1,428,928 backing allocations / 209,090,873 bytes, 84,001 tree-walker entries, and 89,600 Shape requests. The benchmark-only commit will land separately before the enum implementation.

9 days ago

Benchmark boundary landed on main: https://github.com/zig-utils/zig-js/commit/dcee391\n\nThe new representative_intl_date_time_format_resolved_hour_cycle row creates and validates 12,800 fresh resolvedOptions results per 100-job invocation across all four cycles, locale extension resolution, hour12 precedence, and no-hour omission.\n\nBaseline (ReleaseFast, three independent samples): 470.346-478.622 ms, 474.186 ms mean, 0.8793% sample RSD. Exact zig-js checksum: 705814248. Exact system-JSC checksum: 242469243. The #773 dayPeriod divergence remains visible instead of being normalized.\n\nExact zig-js invocation attribution delta: 739,204 managed cells; 1,428,928 backing allocations; 209,090,873 backing bytes; 84,001 tree-walker entries; 89,600 shape transition requests.\n\nFull benchmark gate passed: 58/58 representative-matrix checks, 18/18 harness validators, independent-suite audit, both adapters, and quickening inventory. Runtime acceptance remains open.

9 days ago

Completed on main:\n\n- Implementation: https://github.com/zig-utils/zig-js/commit/66c150f\n- Exact-parent evidence: https://github.com/zig-utils/zig-js/commit/836ac5b\n- Fresh-result Shape witness: https://github.com/zig-utils/zig-js/commit/a553994\n\nSeven order-balanced pairs preserved checksum 705814248. Diagnostic wall medians were 474.578 ms parent and 473.258 ms candidate at 0.95% and 0.89% RSD; instructions, cycles, energy, thermal state, and peak RSS were stable. No speedup claim is made.\n\nThree native attribution replays per binary were exact. Per 12,800 fresh results:\n- managed cells: 739,204 -> 728,004 (-11,200)\n- backing allocations: 1,428,928 -> 1,417,728 (-11,200)\n- backing bytes: 209,090,873 -> 209,057,273 (-33,600)\n- checksum, tree-walker entries, VM entries and dispatches, and Shape transition requests: identical\n\nValidation:\n- full units: 1,940 passed, 1 skipped, 0 failed, 0 leaked\n- focused no-GIL TSan shared-read witness: passed\n- forced tree-walker and required-bytecode differential: passed before and after GC\n- deterministic OOM/publication and exact unmanaged static-cell witnesses: passed\n- Test262 DateTimeFormat: 244 -> 244 pass, 0 -> 0 fail; flips 0, regressions 0\n- benchmark gate: 58/58 representative-matrix checks and 18/18 harness validators, both adapters, independent-suite audit, and quickening inventory\n\nRaw evidence:\n- https://github.com/zig-utils/zig-js/blob/main/docs/.data/exact-parent-intl-date-time-format-hour-cycle-2026-08-26.json\n- https://github.com/zig-utils/zig-js/blob/main/docs/.data/exact-parent-intl-date-time-format-hour-cycle-2026-08-26.md\n\nThe separate pattern-added dayPeriod behavior remains owned by #773; this change does not normalize or close it.

9 days ago

The semantic divergence intentionally left visible by #772 is now resolved in 08a37fe9 (#773). The frozen row now produces zig-js checksum 242469243, exactly matching system JSC, while this issue's native hour-cycle allocation evidence remains unchanged and separately attributable.

Sign in to comment on this issue.