Skip to content

Optimize stream DOM insertions by eliminating Array.from allocations - #4424

Merged
SteffenDE merged 1 commit into
phoenixframework:mainfrom
preciz:perf/dom-patch-stream-allocations
Sep 3, 2026
Merged

Optimize stream DOM insertions by eliminating Array.from allocations#4424
SteffenDE merged 1 commit into
phoenixframework:mainfrom
preciz:perf/dom-patch-stream-allocations

Conversation

@preciz

@preciz preciz commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Assisted-by: Antigravity CLI: Gemini 3.8 Flash

Replaces repeated Array.from conversions with direct HTMLCollection indexing and parent.querySelector(':scope > :not(...)'), eliminating O(M * N) array allocations during stream element insertions. In benchmarks across collection sizes from 200 to 2,000 items, this achieves a 50x–1,400x speedup for indexed insertions and up to an 84x speedup when appending before non-stream children.

Replaces repeated Array.from conversions with direct HTMLCollection indexing and parent.querySelector(':scope > :not(...)'), eliminating O(M * N) array allocations during stream element insertions. In benchmarks across collection sizes from 200 to 2,000 items, this achieves a 50x–1,400x speedup for indexed insertions and up to an 84x speedup when appending before non-stream children.
Comment thread assets/js/phoenix_live_view/dom_patch.ts
@SteffenDE
SteffenDE merged commit d3e3f23 into phoenixframework:main Sep 3, 2026
9 checks passed
@SteffenDE

Copy link
Copy Markdown
Member

🙌🏻

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