Skip to content

Optimize numeric array raw payload helpers - #4957

Merged
proggeramlug merged 3 commits into
mainfrom
feat/perf-investigate-runtime-comparison
Jun 11, 2026
Merged

Optimize numeric array raw payload helpers#4957
proggeramlug merged 3 commits into
mainfrom
feat/perf-investigate-runtime-comparison

Conversation

@TheHypnoo

Copy link
Copy Markdown
Member

Summary

  • Add a hot path for raw-f64 numeric array indexed reads and writes.
  • Avoid revalidating/rebuilding raw numeric layout and per-slot layout notes on every guarded numeric array access.
  • Preserve descriptor/frozen checks and existing fallback paths for non-raw or direct runtime calls.

Performance

Before vs after, median of 3 local runs with Node and Bun included for comparison:

  • bench_string_heavy.ts: Perry 338 ms -> 61 ms (82.0% faster); Node 47 ms, Bun 32 ms after.
  • 10_nested_loops.ts: Perry 13483 ms -> 4347 ms (67.8% faster); Node 19 ms, Bun 19 ms after.
  • 11_prime_sieve.ts: Perry 1503 ms -> 558 ms (62.9% faster); Node 8 ms, Bun 6 ms after.
  • 03_array_write.ts: Perry 3733 ms -> 3390 ms (9.2% faster); Node 12 ms, Bun 9 ms after.
  • 04_array_read.ts: Perry 3700 ms -> 3340 ms (9.7% faster); Node 12 ms, Bun 19 ms after.

Tests

  • cargo test -p perry-runtime numeric_array --quiet
  • Focused Perry-vs-Node output smoke checks for:
    • test-files/test_array_methods.ts
    • test-files/test_array_slice.ts
    • test-files/test_array_of_objects.ts
    • benchmarks/suite/03_array_write.ts
    • benchmarks/suite/04_array_read.ts
    • benchmarks/suite/bench_string_heavy.ts
  • cargo build -p perry --release --quiet

@proggeramlug
proggeramlug merged commit 90bc7bc into main Jun 11, 2026
11 of 13 checks passed
@proggeramlug
proggeramlug deleted the feat/perf-investigate-runtime-comparison branch June 11, 2026 03:22
proggeramlug pushed a commit that referenced this pull request Jun 11, 2026
The numeric-array fast path from #4957 (90bc7bc) added a raw
ptr::write without a GC_STORE_AUDIT marker, so the GC store-site
inventory gate has been red on main since it merged — every PR's lint
fails on it. The write is POINTER_FREE: the RawF64-layout check
guarantees the slot holds a plain f64, never a NaN-boxed pointer.
proggeramlug added a commit that referenced this pull request Jun 11, 2026
…istening' round-trip (#4914) (#4963)

* feat(cluster): workers share a listening port via SO_REUSEPORT + IPC listening round-trip (#4914)

- All 4 TCP listen sites (http/https/http2 in perry-ext-http-server, net.rs)
  bind with SO_REUSEPORT when NODE_UNIQUE_ID marks a cluster worker, so N
  workers share one port.
- Worker reports the bound address to the primary over the fork IPC channel
  ({cmd:"NODE_CLUSTER", act:"listening"}); primary emits 'listening' on the
  worker and the cluster object Node-style.
- Cluster-level lifecycle events: 'online' (deduped between the spawn event
  and the internal online message), 'disconnect', 'exit' (worker, code,
  signal).
- cluster.fork of the compiled binary itself now execs it directly instead
  of `node <native-binary>` (the default exec is current_exe; a native
  executable can't run under node).
- fork honors explicit `silent: false` (cluster's default) as
  inherit-stdio, matching Node; absent silent keeps the historical pipe
  default, explicit stdio still wins.
- Un-stub cluster fork/setupPrimary/setupMaster in the API manifest; regen
  docs; update stub_inventory drift guards.
- e2e test: primary forks 2 workers, both bind one shared port, requests
  round-trip, listening/exit events observed.

SCHED_RR fd-passing and the primary-coordinated shared ephemeral port for
listen(0) are tracked in #4962.

Closes #4914

* fix(lint): GC_STORE_AUDIT marker for the #4957 raw-f64 payload write

The numeric-array fast path from #4957 (90bc7bc) added a raw
ptr::write without a GC_STORE_AUDIT marker, so the GC store-site
inventory gate has been red on main since it merged — every PR's lint
fails on it. The write is POINTER_FREE: the RawF64-layout check
guarantees the slot holds a plain f64, never a NaN-boxed pointer.

---------

Co-authored-by: Ralph Küpper <ralph@skelpo.com>
proggeramlug added a commit that referenced this pull request Jun 11, 2026
…lowering (#4984)

bounded_integer_array_store_omits_layout_note_and_barrier has failed on
main since #4957 (90bc7bc, bisect-confirmed): its `for (i=0; i<arr.length;
i++) arr[i] = i` body is exactly the shape the new
match_numeric_bulk_fill_loop matcher recognizes, so the loop now lowers
to `js_array_fill_f64_iota_len_extend` and the per-element
`js_array_numeric_set_f64_unboxed` the test asserts on is never emitted.
Every PR's required cargo-test check is red until this lands.

Store `i + 1` instead — integer-classified but neither iota nor constant,
so the bulk matcher doesn't fire and the test keeps exercising the
per-element guarded store path it was written for. Add a companion test
pinning the new bulk lowering itself: iota fill over `arr.length` emits
the bulk helper, no per-element stores, and (like the per-element path)
no slot-layout note or write barrier.

Co-authored-by: Ralph Küpper <ralph@skelpo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants