ReviewOS

zig-utils/zig-js

Intl structural services: benchmark and intern part metadata

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

Parents: #475, #460 Depends on: #575, #576

Problem

Intl.ListFormat, Intl.RelativeTimeFormat, and Intl.DurationFormat all expose structural part arrays, but the representative benchmark source has no dedicated rows for these services. Their implementations also allocate fresh string cells for closed type metadata on every returned part, the same ownership cost removed from NumberFormat and DateTimeFormat in #575/#576.

Optimizing without symmetric controls would make allocation and throughput claims unauditable.

Scope

  • Add deterministic, dependency-free formatToParts rows for ListFormat, RelativeTimeFormat, and DurationFormat with formatter/input fixture construction outside the timed boundary.
  • Consume complete type/value/unit structure in stable checksums and compare identical source/input bytes with system JSC.
  • Attribute exact-parent allocations, GC cells, collections, locks, and timing before changing the engine.
  • Represent each service's closed part-type metadata natively and emit process-lifetime immutable string cells.
  • Keep formatted values and DurationFormat unit fields independently owned; preserve ordinary mutable result arrays/objects and callback-observable semantics.

Acceptance

  • All three rows have stable, non-zero checksums and meet the harness timing protocol.
  • Checksums match system JSC, or any pre-existing semantic delta is isolated and separately tracked before optimization.
  • Exact-parent attribution demonstrates fewer structural metadata allocations without increasing collections or property locks.
  • Focused ListFormat/RelativeTimeFormat/DurationFormat normal, OOM, moving-GC, bounded-heap, no-GIL, and TSan coverage pass.
  • Relevant Intl402 subtrees and full sharded units have no regressions.

Exclusions

No Promise, microtask, Worker, queue, or job-lifecycle changes; those remain separately owned.

9 days ago

Benchmark boundary landed on main in bench(intl): isolate structural service metadata (#577).

The three rows preconstruct formatters/inputs and consume every returned type, value, and DurationFormat unit byte. At 320 jobs, both engines clear the 50 ms floor and checksums exactly match system JSC:

  • ListFormat parts: 650961865
  • RelativeTimeFormat parts: 629639089
  • DurationFormat parts: 588161046

Exact-parent attribution at 100 jobs freezes the pre-implementation allocation boundary:

  • ListFormat: 2,512,046 backing allocations / 336,083,475 bytes; 1,463,587 GC cells; 52 collections
  • RelativeTimeFormat: 1,516,851 backing allocations / 206,374,256 bytes; 831,599 GC cells; 31 collections
  • DurationFormat: 6,195,257 backing allocations / 782,486,068 bytes; 3,434,800 GC cells; 121 collections

benchmark-comparison-test passes. Engine metadata ownership is the next commit in this issue.

9 days ago

Completed in perf(intl): intern structural service metadata (#577).

ListFormat, RelativeTimeFormat, and DurationFormat now represent closed part types with native enums backed by process-lifetime immutable string cells. Dynamic value and unit fields remain independently owned, and result arrays/objects remain ordinary and mutable.

Exact-parent 100-job attribution, with exact checksums and unchanged property-lock counts:

  • ListFormat: backing allocations 2,512,046 -> 2,438,444, bytes 336,083,475 -> 335,646,309, GC cells 1,463,587 -> 1,389,987, collections 52 -> 51.
  • RelativeTimeFormat: backing allocations 1,516,851 -> 1,480,049, bytes 206,374,256 -> 206,050,224, GC cells 831,599 -> 794,799, collections 31 -> 30.
  • DurationFormat: backing allocations 6,195,257 -> 6,080,055, bytes 782,486,068 -> 781,724,996, GC cells 3,434,800 -> 3,319,600, collections 121 -> 120.

Order-balanced timings were mixed, so no latency claim is made. Conformance remains ListFormat 81/81, RelativeTimeFormat 80/80, DurationFormat 110/110, and Intl402 3,341/3,341 with 0 flips. Focused normal and TSan coverage pass 4/4, including bounded precise heap, moving nursery, and four-lane no-GIL publication. Full units pass 1,662, with 1 intentional skip, 0 failures, and 0 leaks.

Sign in to comment on this issue.