Skip to content

Hot-loop performance: cube generation and tick-path micro-costs - #4604

Open
lbwexler wants to merge 2 commits into
hot-loop-perf-3from
hot-loop-perf-4
Open

Hot-loop performance: cube generation and tick-path micro-costs#4604
lbwexler wants to merge 2 commits into
hot-loop-perf-3from
hot-loop-perf-4

Conversation

@lbwexler

Copy link
Copy Markdown
Member

Fourth batch in the stack (#4600#4602#4603 → this) - pure internal reorg in the cube package, no API or behavior changes.

  • View.getField: reads a Map built eagerly in buildIndices() (renamed from buildAggFields - it now builds all per-query field collections together) - was a lodash {name} matcher find per forced field per row per generation via recomputeAggregatesForContextChange.
  • View.hasDimOrBucketUpdates: iterates dimensions and bucket-dependent fields directly - drops the per-tick Array.from + spread + uniq array 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 - _bucketDependentFields rebuilds each generation, so a cache would need its own invalidation story.
  • BaseRow.getChildrenDatas: single pass folding null-filtering and flattening into one loop - was flatMap + compact (two full arrays and two passes per parent per generation; material mainly for includeLeaves/provideLeaves views, where leaves flow through this path).
  • UniqueAggregator: === short-circuit ahead of isEqual in both aggregate (per child) and replace, dropping the per-row Array.every callback. Semantics identical - isEqual still runs for non-reference-identical values, and NaN falls through to isEqual exactly 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.

* 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.
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.

1 participant