opt: skip allocation hot spots in elementify and handleScope#145
Open
opt: skip allocation hot spots in elementify and handleScope#145
Conversation
Avoids 4 ST ref allocations (newStaticRegion) + 1 STRef.new(-1) per leaf element. Benchmark has ~2k leaf elements per 1k rows (empty td, span). Result: 455ms median vs 494ms opt1 baseline (~7.7% gain). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add isDisposalQueueEmpty to PSR record (cheap: array.length check) - handleScope now skips pump/subscription setup when queue is empty - elementify/text skip handleRemove push for elements with element parent (hasElementParent=true means the lazy 'when false' handler is never called) Combined effect: ~5/9 elements per row skip the expensive handleScope path (Event.create + 2 ST.new + subscribeO per element). Saves ~64ms/1k rows. Result: 391ms median vs 455ms opt3 baseline (~14% improvement). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Two sequential optimizations targeting allocation hot spots in
01_run1k(js-framework-benchmark):opt3: skip fromParent+aref for leaf elements with empty children
newStaticRegion) + 1STRef.new(-1)per leaf elementtd,span)opt4: skip handleScope for elements with empty disposal queue
isDisposalQueueEmptyto PSR (cheaparray.length === 0check)handleScopeskipspump+ subscription setup when queue is empty — savesEvent.create + 2 ST.new + subscribeOper skipped elementelementify/textskipaddEffectToDisposalQueuefor elements with an element parent (hasElementParent=true), since their removal handler is never reachablehandleScopepathTest plan
🤖 Generated with Claude Code