perf(zql): optimize Join processParentNode closure and spread#5608
Draft
Karavil wants to merge 1 commit intorocicorp:mainfrom
Draft
perf(zql): optimize Join processParentNode closure and spread#5608Karavil wants to merge 1 commit intorocicorp:mainfrom
Karavil wants to merge 1 commit intorocicorp:mainfrom
Conversation
Extract inline child stream closure to a #fetchChildStream method to reduce per-call allocation. Skip object spread of parentNodeRelations when empty (common for leaf joins). Part of IVM pipeline perf optimizations that reduced page freeze from ~7.7s to <1s in a production app. * Extract #fetchChildStream(parentNodeRow) method from inline closure * Add empty-check for parentNodeRelations before spreading * No behavioral changes - pure optimization
|
Someone is attempting to deploy a commit to the Rocicorp Team on Vercel. A member of the Team first needs to authorize it. |
This was referenced Feb 25, 2026
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
Optimize
Join#processParentNodeby extracting the child stream closure to a method and skipping the object spread whenparentNodeRelationsis empty.Motivation
#processParentNodeis called for every parent row during join fetch and push operations. In a workload with 135 IVM pipelines, many of which involve joins with ~200 child rows per parent, this method is called tens of thousands of times per page render.Two specific costs:
#processParentNodeon every call. Extracting the logic to a class method (#fetchChildStream) means we create a lightweight arrow function that delegates to the method, rather than a closure capturing local constraint-building logic.parentNodeRelationsis an empty{}. The{...parentNodeRelations, [name]: stream}spread still allocates a new object and copies all (zero) properties. Checking emptiness withfor...inand skipping the spread avoids this overhead.Changes
#fetchChildStream(parentNodeRow)private method#processParentNode: check ifparentNodeRelationshas any keys viafor...in, skip the spread if emptyExpected Performance Impact
For leaf joins (bottom of a join chain), the spread skip avoids unnecessary object creation on every parent row. The method extraction reduces closure allocation overhead. Together, these reduce per-call overhead in the most frequently called join method.
Testing