1390 Commits
Author SHA1 Message Date
Chris Tate ddacf49d11 Merge pull request #875 from vercel-labs/ctate/prepare-v0-2-02ac14
Prepare v0.2.9
v0.2.9
2026-10-11 18:02:02 -05:00
Chris Tate 6adb753e89 Correct the runtime ABI version in the 0.2.9 notes 2026-10-11 17:32:45 -05:00
Chris Tate fa11424e5f Prepare v0.2.9 2026-10-11 17:25:14 -05:00
Chris Tate 83dce99e51 Merge pull request #874 from vercel-labs/ctate/give-sanitized-emitter-dec393
Give the sanitized emitter CI job swap and a larger stack
2026-10-11 17:23:51 -05:00
Chris Tate 3bf0d0b9a5 Give the sanitized emitter job swap and a larger stack
The sanitized native emitter peaks near 13 GB while it emits the
compiler and then compiles the 348 MB module with clang under
AddressSanitizer, which together exceed the 16 GB runner. Back the
rebuild-emit job with a 24 GiB swap file and lift its stack limit,
since the instrumented emitter's recursion can exceed 8 MiB.
2026-10-11 16:45:12 -05:00
Chris Tate c9452c8c33 Merge pull request #867 from vercel-labs/perf/checker-round4
PR: Read nullable-union array elements inline and borrow them for preserving live ranges
2026-10-11 15:25:09 -05:00
Chris Tate 8706ceafcf Merge pull request #866 from vercel-labs/ctate/check-index-guard-9174bc
Check the index guard in the integer byte-loop test
2026-10-11 15:17:22 -05:00
Chris Tate 187ca8b998 Check the index guard in the integer byte-loop test 2026-10-11 15:05:18 -05:00
Chris Tate aaccbb3908 Merge pull request #856 from vercel-labs/perf/array-layout-main
Move rarely used array storage out of line
2026-10-11 14:59:03 -05:00
Chris Tate c2ee2b8cf1 Merge pull request #861 from vercel-labs/perf/gc-trace-null-skip-main
Skip null slots in emitted trace functions
2026-10-11 14:57:10 -05:00
Chris Tate 1f0e66566d Merge main into perf/array-layout-main 2026-10-11 14:55:17 -05:00
Chris Tate 6eef5b7e5a Merge main into perf/gc-trace-null-skip-main 2026-10-11 14:54:07 -05:00
Chris Tate 976342876c Merge pull request #865 from vercel-labs/ctate/update-constant-table-dd172e
Update constant-table emission test for exact index checks
2026-10-11 14:52:54 -05:00
Malte Ubl 7cdbfc26a9 Format local-array-reads and record the preflight baseline for corpus 4671 2026-10-11 12:49:26 -07:00
Chris Tate f3cfa80a8e Update byte-loop emission test for exact index checks 2026-10-11 14:48:03 -05:00
Chris Tate 9b80f3d4b4 Update constant-table emission test for exact index checks 2026-10-11 14:45:30 -05:00
Chris Tate 988e78c323 Merge pull request #855 from vercel-labs/perf/heap-layout-main
Shrink cycle-capable objects: typed rest spreads, a 16-byte collector header, leaf capture boxes
2026-10-11 14:42:35 -05:00
Malte Ubl fc93d10871 Merge remote-tracking branch 'origin/perf/array-layout-main' into HEAD 2026-10-11 12:23:05 -07:00
Malte Ubl cc8392d26a Merge remote-tracking branch 'origin/perf/heap-layout-main' into HEAD 2026-10-11 12:22:56 -07:00
Malte Ubl c8430bbf0d Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	packages/compiler/test/ts7/baselines/order-parity.json
2026-10-11 12:22:49 -07:00
Malte Ubl 20029454ef Read nullable-union array elements inline and borrow them for preserving live ranges
Optional array reads also match arrays whose element is itself the read T | undefined nullable-pointer union; owned copies retain and release through its NULL-tolerant entry points. A local array read borrows when its array operand is rooted at a stable parameter and its own live range preserves heap edges, and a call-argument read borrows when the call preserves them. An optional chain on such a read borrows the inline element instead of taking a second reference.
2026-10-11 12:20:28 -07:00
Chris Tate baeaf9c7e0 Merge pull request #854 from vercel-labs/perf/exception-flag-main
Exact per-thread pending word for worker executables, and a call-free macOS stack guard
2026-10-11 14:06:38 -05:00
Chris Tate c293844bd9 Merge pull request #853 from vercel-labs/perf/exception-checks-main
Fewer termination polls in worker programs
2026-10-11 13:42:45 -05:00
Chris Tate b2bb6fa173 Merge main into perf/exception-checks-main 2026-10-11 13:38:06 -05:00
Chris Tate 0ab65a79b0 Merge pull request #836 from vercel-labs/perf/parmem
Support os.availableParallelism() in static programs
2026-10-11 12:55:51 -05:00
Chris Tate 50e223d86c Merge pull request #862 from vercel-labs/perf/gc-type-bypass-main
Let collector types bypass the generations where they never die
2026-10-11 12:55:12 -05:00
Chris Tate 60d5b258df Merge pull request #860 from vercel-labs/perf/detached-exit
Free the address space after process.exit off the critical path (`--detached-exit`)
2026-10-11 12:19:16 -05:00
Malte Ubl 00f88680cd Merge remote-tracking branch 'origin/main' into HEAD 2026-10-11 10:17:26 -07:00
Malte Ubl 112add3dce Merge remote-tracking branch 'origin/perf/gc-trace-null-skip-main' into HEAD
# Conflicts:
#	packages/compiler/test/ts7/baselines/order-parity.json
2026-10-11 10:17:20 -07:00
Malte Ubl dab7719e28 Merge remote-tracking branch 'origin/perf/array-layout-main' into HEAD 2026-10-11 10:17:13 -07:00
Malte Ubl 796013f9d2 Merge remote-tracking branch 'origin/perf/heap-layout-main' into HEAD
# Conflicts:
#	packages/compiler/test/ts7/baselines/order-parity.json
2026-10-11 10:17:07 -07:00
Malte Ubl fca66ec655 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	packages/compiler/test/ts7/baselines/order-parity.json
2026-10-11 10:16:59 -07:00
Malte Ubl a34d018497 Merge remote-tracking branch 'origin/perf/exception-checks-main' into HEAD 2026-10-11 10:16:45 -07:00
Malte Ubl 445730ee38 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	packages/compiler/test/ts7/baselines/order-parity.json
2026-10-11 10:16:37 -07:00
Malte Ubl fe79aea42e Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	packages/compiler/test/ts7/baselines/order-parity.json
2026-10-11 10:15:10 -07:00
Chris Tate 2db40a34e8 Merge pull request #859 from vercel-labs/perf/worker-fd-table
Grow the descriptor table before worker threads share it
2026-10-11 12:07:56 -05:00
Chris Tate 727bdb7227 Merge pull request #849 from vercel-labs/perf/gc-widen-faster
Widen the old level's growth fraction two doublings at a time
2026-10-11 12:07:34 -05:00
Chris Tate e503d26b17 Merge pull request #842 from vercel-labs/perf/exact-index-checks
Cheaper checks for unproven typed-array and string indexes
2026-10-11 12:06:42 -05:00
Chris Tate c0cedd769c Merge pull request #840 from vercel-labs/perf/borrow-optional-chain-receivers
Borrow the bound receiver of optional chains
2026-10-11 12:06:17 -05:00
Chris Tate 12da5538f7 Merge pull request #834 from vercel-labs/perf/live-typed-ref-access
Access live array references one element at a time
2026-10-11 12:05:44 -05:00
Malte Ubl 554f3177ab Walk sampled bypass candidates at the nursery level in the cycle test
check_nursery_bypass's last phase releases WINDOW * SAMPLE dead rings of a
nursery-bypassed type and expects the sampled one in SAMPLE to complete a
nursery window, which turns the bypass off. That is exactly one window of
sampled candidates, so it held only while no older pass ran during the
phase. Under the growth cap's default of 16 (main's SCR_CYCLE_GROWTH_CAP,
with the cap's checks now running before the bypass checks) the promoted
rings trigger mature passes that also sweep sampled nursery candidates:
the nursery counted 4544 of its 8192 walks, kept the bypass, and the check
failed at the default and 64 caps (caps 1 and 2 passed).

The phase now runs a nursery pass after each release, as the mature check
already runs passes at exact levels, so every sampled candidate is walked
by its own level. The collector is unchanged. The check still fails with a
sticky bypass decision and without sampling, at caps 16 and 1.
2026-10-11 09:57:08 -07:00
Malte Ubl f4eafed2b5 Number collector types in the self-hosting layout fixture
Emitted ScrCycType descriptors now carry collector statistics indices from ShapeHost.nextCycKind, counted from FIRST_EMITTED_CYC_KIND. The llvm-layouts.ts host lacked the hook, so its class descriptors and vtables stamped kind 0 and the native layout emission diverged from the production emitter's.
2026-10-11 09:39:58 -07:00
Malte Ubl def6f86a0e Let collector types bypass the generations where they never die
Nearly every long-lived object becomes a cycle candidate once, soon after
it is built: the constructing frame's release leaves it held only by the
structure it was stored into. A nursery pass then walks it (about 75 ns per
object), it survives, and it is re-buffered for the mature level, whose
next pass walks it again. In tsc-ts single-threaded, nursery passes walked
6.0M objects on Excalidraw and 36.5M on Sentry and freed 7%; 99% of what
they walked was promoted. Most of that walking goes to types whose objects
never die in a young cycle: SymbolLinks, NodeLinks and Symbol were 2.0M of
Excalidraw's candidates and the collector freed none of them, while young
garbage comes from a few types (inference contexts and mappers, closures,
some arrays). Types with a collector yield under 0.5% are 42-55% of what
nursery passes walk.

So the collector now keeps per-thread statistics per type and level. Each
ScrCycType gains a `kind` index: emitted descriptors number themselves from
32 (FIRST_EMITTED_CYC_KIND / SCR_CYC_KIND_EMITTED), the runtime's own
families have fixed kinds below that, 0 keeps no statistics. For the
nursery and mature levels, a pass counts the candidates of each kind it
walks and the objects of each kind it frees. After every 8192 walked
candidates a kind bypasses that level for the next window if fewer than 1
in 128 of them were freed. A release that buffers an object at a level its
type bypasses promotes it past the level first, and a nursery pass that
re-buffers a survivor into a bypassed mature level moves it to the old
level. One candidate in 16 stays put, so the yield keeps being measured
and a type whose objects start dying young again is walked again after
one window.

Only the generation an object is judged in changes. Any assignment is
sound (a restricted pass counts edges from older objects as external), a
bypassing candidate stays buffered, and full passes walk everything they
did before, so the old level's bounds hold unchanged. Cyclic garbage made
only of objects of a bypassing type waits for the next pass at an older
level. Programs that never complete a window (8192 walked candidates of one
type) are collected exactly as before.

The descriptor layout is part of the emitted-code/runtime ABI, so the
program-object marker moves to scr_runtime_abi_v12.

Pass log (instrumented build, single-threaded, one run each, with the
preceding null-slot change): all collector passes Excalidraw 606 -> 313 ms
(nursery 435 -> 153), TypeORM 629 -> 383 ms, tsc-ts self-check 377 -> 215
ms, Sentry 7.61 -> 5.75 s (nursery 2.92 -> 1.04 s, mature 1.17 -> 1.02 s;
the full pass is unchanged at 3.6 s).

tsc-ts (Linux sandbox, interleaved, medians; 10 rounds, Sentry 5 rounds
pinned to 8 CPUs; both changes against int/best-v6): single-threaded
Excalidraw -8.0%, TypeORM -4.2%, self-check -4.3%, Sentry -5.3%;
--checkers 8 -12.2%, -0.8%, -2.3%, -1.6%. Peak RSS -0.8% to +0.6%.
Diagnostics identical.

Tests: test_cycle gains check_nursery_bypass, check_mature_bypass and
check_rebuffer_past_mature (a test-only entry point, scr_cyc_pass_at under
SCR_CYC_TESTING, runs passes at exact levels); each fails under the
corresponding mutation (no bypass, a sticky decision, no sampling, no freed
or walked counts, a bypassing candidate left unbuffered, survivors
re-buffered into a bypassed level). Corpus 4690 builds a long-lived
declaration graph large enough for both levels to bypass and lets objects
of the same classes die in cycles; under --sanitize the exit RC audit
proves they are reclaimed.
2026-10-11 09:39:57 -07:00
Malte Ubl af7a1bdfed Skip null slots in emitted trace functions
Emitted class and record trace functions passed every traced slot to the
visitor, empty ones included, and the visitor's first test dropped them.
Most traced slots of a large heap are empty (optional links, unset caches):
in tsc-ts, 56% of the child edges the nursery's markGray visited were null
(Excalidraw 18.5M of 33M per single-threaded run, Sentry 111M of 210M), and
full passes visited about as many. Each was an indirect call, and the
restoring scan made it again.

Trace functions now test each loaded slot and skip the call for null. Every
collector visitor already ignores null children and the collector is the
only caller of trace functions, so what a pass walks is unchanged.

tsc-ts (Linux sandbox, interleaved, 5 rounds, medians): single-threaded
Excalidraw -2.6%, TypeORM -2.4%, self-check -2.0%; --checkers 8 -8.6%,
-8.2%, -3.3%. Peak RSS within +-1%. tsc-ts binary +20,408 bytes (+0.09%).
2026-10-11 09:38:28 -07:00
Malte Ubl 85aa553ee4 Skip out-of-line array storage work for arrays without it
Destroying an array released its metadata and freed its sparse and
property storage through calls that took the shared empty ext, so every
array paid four calls on NULL. Check the ext once and free it in one
place; truncating length likewise skips the sparse search without one.
2026-10-11 09:38:28 -07:00
Malte Ubl 4fd8d5d3b5 Give the self-hosting layout fixture the cycle header's buffered offset
The 16-byte collector header replaced ClassHost.cycleColorOffset with cycleBufferedOffset (6 bytes behind every object on every target); llvm-layouts.ts still set the removed property and lacked the required one.
2026-10-11 09:38:27 -07:00
Malte Ubl 30a4d8b284 Allocate an array's out-of-line storage from the small-object allocator
The ext struct came from the system calloc, which every regex match result
(whose metadata lives there) paid for: regex-logs ran 1.9% slower in the
runtime suite. It now comes from scr_mem_calloc and returns through
scr_mem_free, like the array itself.
2026-10-11 09:38:27 -07:00
Malte Ubl 1a14263b5f Move rarely used array storage out of line
Every ScrArr carried sixteen words, seven of them (sparse slots, their
length and capacity, noncanonical numeric properties with length and
capacity, and match-result metadata) used only by sparse arrays, arrays
with numeric non-index properties and regex match results. They now live in
a ScrArrExt the array points at, allocated on first use: a dense array
shrinks from 128 to 80 bytes, and a cycle-capable one (with its 16-byte
collector header) from 144 to 96.

Runtime readers go through a shared empty ext; writers allocate it. The
backend mirror loses the seven fields, tagged-template arrays are emitted
with a NULL ext, live stream commits swap the ext pointer (which swapped all
seven fields before), and the cached typed-view refresh swaps sparse slots
and properties through scr_arr_swap_indexed_ext, keeping each array's
metadata as before. The program-object ABI marker moves to
scr_runtime_abi_v11.

A corpus program (4610-array-ext-dyn-refresh.ts, with its order baseline) pins numeric non-index properties of a dynamically typed array through its refreshed typed view, sparse slots written directly and through a live reference, truncation, and regex match metadata read directly, through `any` and after a copy.
2026-10-11 09:38:27 -07:00
Malte Ubl bb478e1e6c Buffer only capture boxes that can lie on a cycle
Every release that left a capture box alive buffered it as a cycle candidate, but a box's trace visits its payload only for a closure or a class instance with a cycle header. Boxes holding numbers, booleans, strings, arrays or acyclic instances are leaves of the object graph and can never be on a garbage cycle; they still cost an enqueue and, when they die, a dequeue. On Excalidraw boxes were 18% of all buffered candidates (1.76M of 10.3M).

scr_box_release and the emitted inline release (speed builds) now test kind == SCR_BOX_FUNC || obj_trace != NULL first, mirroring the union boxes' arm_trace test.
2026-10-11 09:38:26 -07:00
Malte Ubl 6f488e13aa Shrink the cycle-collector header to 16 bytes
Every cycle-capable object carried a 32-byte header: trace and teardown function pointers, a 32-bit color, the buffered flag, the generation and a 64-bit candidate index. The two function pointers are the same for every object of a type, so the header now points at one constant ScrCycType { trace, free_fn } descriptor per type, and the remaining fields pack into the second word: u8 color, u8 gen, u16 buffered, u32 buf_index (candidate buffers stop at 2^31 entries). wasm32 pads before the descriptor, so every object-relative offset is the same on all targets.

Emitted shapes define their descriptor next to the trace and teardown functions; inline allocation stores one header word; the inline release reads buffered at obj-6 and the inline free reads the generation as an i8 at obj-7. Runtime families allocate with static descriptors. The program-object ABI marker moves to scr_runtime_abi_v10.

tsc-ts (interleaved, 5 rounds): peak RSS -8% to -11% on every app and mode; single-threaded wall -0.3% to -5.5% on top of the typed-rest-spread change.
2026-10-11 09:38:26 -07:00