Skip to content

perf(core): use index-based SafeArrayIterator in primordials - #36543

Merged
bartlomieju merged 1 commit into
denoland:mainfrom
petamoriken:perf/primordials
Aug 12, 2026
Merged

bartlomieju merged 1 commit into
denoland:mainfrom
petamoriken:perf/primordials

Conversation

@petamoriken

Copy link
Copy Markdown
Contributor

Avoid allocating a real ArrayIterator and calling the user-patchable ArrayIteratorPrototype.next path. Microbenches show ~1.1–2.7× speedup depending on for-of vs spread call patterns.

Track exhaustion explicitly so an iterator remains done after its backing array grows, matching built-in ArrayIterator semantics. Add regression coverage for resuming after an early exit and remaining done after exhaustion.

I used Codex for this implementation.

Avoid allocating a real ArrayIterator and calling the user-patchable ArrayIteratorPrototype.next path. Microbenches show ~1.1–2.7× speedup depending on for-of vs spread call patterns.

Track exhaustion explicitly so an iterator remains done after its backing array grows, matching built-in ArrayIterator semantics. Add regression coverage for resuming after an early exit and remaining done after exhaustion.

@bartlomieju bartlomieju left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bartlomieju
bartlomieju merged commit 135485c into denoland:main Aug 12, 2026
136 checks passed
@petamoriken
petamoriken deleted the perf/primordials branch August 12, 2026 10:48
bartlomieju pushed a commit that referenced this pull request Aug 27, 2026
Avoid allocating a real `ArrayIterator` and calling the user-patchable
`ArrayIteratorPrototype.next` path. Microbenches show ~1.1–2.7× speedup
depending on for-of vs spread call patterns.

Track exhaustion explicitly so an iterator remains done after its
backing array grows, matching built-in `ArrayIterator` semantics. Add
regression coverage for resuming after an early exit and remaining done
after exhaustion.
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