Hot-loop performance: cube generation and tick-path micro-costs - #4604
Open
lbwexler wants to merge 2 commits into
Open
Hot-loop performance: cube generation and tick-path micro-costs#4604lbwexler wants to merge 2 commits into
lbwexler wants to merge 2 commits into
Conversation
* View.getField reads a Map built eagerly in buildIndices (renamed from buildAggFields) alongside the other per-query field collections - was a lodash matcher find per forced field per row per generation. * View.hasDimOrBucketUpdates iterates dimensions and bucket-dependent fields directly - drops the per-tick Array.from/spread/uniq array assembly and the per-record closure. A field in both lists is now compared twice per record - an accepted nanosecond redundancy vs rebuilding a deduped list every tick. * BaseRow.getChildrenDatas builds its result in a single pass, folding null filtering and flattening into one loop - was flatMap + compact (two arrays, two passes per parent per generation). * UniqueAggregator short-circuits on === before isEqual in aggregate (per child) and replace, and drops the per-row Array.every callback.
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.
Fourth batch in the stack (#4600 → #4602 → #4603 → this) - pure internal reorg in the cube package, no API or behavior changes.
Mapbuilt eagerly inbuildIndices()(renamed frombuildAggFields- it now builds all per-query field collections together) - was a lodash{name}matcherfindper forced field per row per generation viarecomputeAggregatesForContextChange.Array.from+ spread +uniqarray assembly and the per-changed-record closure allocation. A field appearing in both lists is now compared twice per record: an accepted nanosecond redundancy (identical short-circuiting test) vs rebuilding a deduped list on every tick. Caching the merged list was rejected -_bucketDependentFieldsrebuilds each generation, so a cache would need its own invalidation story.flatMap+compact(two full arrays and two passes per parent per generation; material mainly forincludeLeaves/provideLeavesviews, where leaves flow through this path).===short-circuit ahead ofisEqualin bothaggregate(per child) andreplace, dropping the per-rowArray.everycallback. Semantics identical -isEqualstill runs for non-reference-identical values, and NaN falls through toisEqualexactly as before.Validated in Toolbox: cube-backed tree grid loads with internally-consistent totals (region P&Ls sum exactly to the summary row), expand-all, and regroup to the 5-level Fund›Region›Trader›Sector›Symbol favorite incl. Minor Positions bucket rows. Zero console errors.