ReviewOS

zig-utils/zig-js

Intl.NumberFormat: intern structural part metadata

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

Parent: #475 Depends on: #567, #568, #569, #570, #571, #575

Problem

Intl.NumberFormat.prototype.formatToParts and formatRangeToParts allocate fresh StringCell and backing copies for every type and source value. NumberFormat produces those metadata values from a closed specification-owned set, while only formatted value bytes require result-owned storage.

Exact-parent (9baffa8c) attribution at 100 jobs records:

  • generic parts: checksum 14300800, 281,594 backing allocations / 45,795,716 bytes, 244,280 GC-cell allocations, 6 collections
  • generic range parts: checksum 61415241, 673,706 backing allocations / 76,310,207 bytes, 636,393 GC-cell allocations, 15 collections

The generic parts checksum matches system JSC. Range-parts attribution is measured against the exact parent because that broad mixed-style row is not the dedicated #570 differential oracle.

Scope

  • Represent the closed NumberFormat part-type set with a native enum mapped to process-lifetime immutable string cells.
  • Share the already-closed Intl range-source representation with DateTimeFormat.
  • Replace internal part-type string comparisons with enum comparisons.
  • Keep every formatted value independently owned and preserve ordinary mutable part arrays/objects.
  • Preserve exact BigInt input, digit translation, range collapse, plural-range behavior, property order, and source attribution.

Acceptance

  • Generic parts/range-parts checksums remain exact against the parent; dedicated NumberFormat differential controls remain exact against JSC.
  • Attribution demonstrates fewer backing allocations/bytes and GC cells without increasing collections or property locks.
  • NumberFormat and full Intl402 test262 subtrees have no regressions.
  • Focused normal, TSan, OOM, moving-GC, bounded-heap, and no-GIL coverage pass.
  • Full sharded units pass.

Exclusions

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

9 days ago

Landed on main in perf(intl): intern NumberFormat part metadata (#576).

NumberFormat part types now use a closed native enum, and NumberFormat/DateTimeFormat share one closed Intl range-source enum. Metadata is exposed through process-lifetime immutable string cells; dynamic formatted values remain independently owned and returned arrays/part objects remain ordinary mutable JavaScript objects.

Exact-parent (9baffa8c) evidence at 100 jobs:

  • parts: backing allocations 281,594 -> 225,596 (-19.89%), GC cells 244,280 -> 188,280 (-22.92%), collections 6 -> 6, cumulative backing bytes 45,795,716 -> 45,432,916
  • range parts: backing allocations 673,706 -> 442,627 (-34.30%), GC cells 636,393 -> 405,313 (-36.31%), collections 15 -> 11, cumulative backing bytes 76,310,207 -> 64,635,483 (-15.30%)
  • property-lock counts are unchanged
  • generic parent checksums remain exact: parts 14300800, range parts 61415241
  • dedicated compact/currency parts and range-parts checksums remain exact against system JSC
  • opposite-order 11-sample range-parts medians: 0.873x / 0.937x parent; the smaller parts row is 0.973x / 1.000x, so no standalone throughput claim is made for it

Verification:

  • NumberFormat 249/249
  • full Intl402 3,341/3,341
  • affected flips 0
  • focused normal and TSan 13/13, including bounded heap, OOM, moving GC, no-GIL, exact BigInt, and generated locale data
  • full units 1,658 pass / 1 skip / 0 fail / 0 leak
  • format and diff checks clean

Sign in to comment on this issue.