Repository navigation
perf(runtime): speed up iterable_array_from for arrays - #59
Merged
Merged
Conversation
Copy array elements by index instead of allocating an iterator and a
{ value, done } result per item. Skip comparison and sparse-hole
materialization stay aligned with the iterator path.
Co-authored-by: Jon Wheeler <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
jonkwheeler
marked this pull request as ready for review
September 4, 2026 14:33
leonidaz
requested changes
Sep 4, 2026
Comment on lines
+94
to
+96
| if (is_array(iterable)) { | ||
| return array_from_index(iterable, index); | ||
| } |
Contributor
There was a problem hiding this comment.
we don't need an extra function, this should just be:
Suggested change
| if (is_array(iterable)) { | |
| return array_from_index(iterable, index); | |
| } | |
| if (is_array(iterable)) { | |
| return array.slice(index); | |
| } |
Contributor
There was a problem hiding this comment.
the reason is if it's even a holey array, we still want holes to be present, we're not changing that.
Contributor
There was a problem hiding this comment.
Dropped the helper and switched the array path to iterable.slice(index), so holey arrays keep their holes. Tests now assert slice hole semantics.
This was referenced Sep 4, 2026
Contributor
|
READY FOR REVIEW |
Use Array.prototype.slice for the array fast path and keep holes in holey arrays, as requested in review. Co-authored-by: Jon Wheeler <[email protected]>
leonidaz
approved these changes
Sep 4, 2026
Merged
cursor Bot
pushed a commit
that referenced
this pull request
Sep 4, 2026
Keep #59 array slice path and this branch's non-array indexed copy. Strings stay on the iterator path. Co-authored-by: Jon Wheeler <[email protected]>
cursor Bot
pushed a commit
that referenced
this pull request
Sep 4, 2026
Declare arguments-IIFE parameters so checkJs accepts the call, and narrow length access on the iterable union without changing runtime behavior. Co-authored-by: Jon Wheeler <[email protected]>
cursor Bot
pushed a commit
that referenced
this pull request
Sep 4, 2026
…#66) * perf(runtime): speed up iterable_array_from for length-bearing values Copy indexed elements for non-array array-likes, arguments, strings, and typed arrays instead of walking Symbol.iterator or allocating through Array.from().slice(). Arrays stay on the iterator path. Co-authored-by: Jon Wheeler <[email protected]> * fix(runtime): keep string iterable_array_from on the iterator path String.prototype[Symbol.iterator] yields Unicode code points, so the indexed copy split non-BMP surrogate pairs and changed skip offsets. Co-authored-by: Jon Wheeler <[email protected]> * fix(runtime): satisfy typecheck after the #59 merge Declare arguments-IIFE parameters so checkJs accepts the call, and narrow length access on the iterable union without changing runtime behavior. Co-authored-by: Jon Wheeler <[email protected]> --------- Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: Jon Wheeler <[email protected]>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
iterable_array_fromaccepted arrays but always walkedSymbol.iterator, allocating an iterator and a{ value, done }result per element. Arrays now useiterable.slice(index), which keeps holes in holey arrays.Sets, raw iterators, and array-likes are unchanged.
Audit notes
@tsrx/runtimeis compiler helpers (refs, spreads,@formapping), not a signals/effects runtime. Other hot paths were measured before landing this:map_iterable/map_array— already specialized for arrays. Preallocation, nativemap, and flatten variants were mixed or regressing across list sizes (10 / 100 / 1000) and vnode vs text vs fragment workloads.normalize_spread_props— rest-arg removal and indexedownKeyswere inside noise (~1–4%). This path was just tuned in perf(runtime): speed up ordinary spread normalization #42.normalize_spread_props_for_ref_attrin-placedefineProperty— ~0–3%, overlapping quartiles.exclude_prop_from_objectdefinePropertiesbatch — −20%.Only the array fast path in
iterable_array_fromwas a clear, reproducible win.Benchmarks
Node
v22.14.0, linux x64, isolatedperf_hooksmicrobenchmarks (warmup 200ms, 400ms × 13 runs, median).Array.prototype.slicevs the previous iterator walk (same-process bake-off):sliceSet / iterator workloads stay on the existing path.
Test plan
slice, index edge cases, holey-array holes, Set, iterator, and array-likepnpm exec vitest runon language-helpers runtime and type tests (2 files, 15 tests) after the review follow-up