Repository navigation
perf(schema-compiler): Deduplicate join tree edges by reference - #12560
Conversation
|
Claude finished @paveltiunov's task in 43s —— View job LGTM: 0 high, 0 medium, 1 low. Deduplicating by reference gives the same result as Review details
CorrectnessThe change is safe. Findings
Other areas
Review threadsThe listing returned 0 of my own threads. Nothing was resolved or re-affirmed. |
|
Generated by Claude Code |
|
There's no fix on master yet. This patch fixes it, and I've verified it locally on master: --- a/packages/cubejs-model-schema/package.json
- "version": "1.8.16",
+ "version": "1.8.17",
- "@cubejs-backend/linter": "1.8.16",
- "@cubejs-backend/schema-compiler": "1.8.16",
+ "@cubejs-backend/linter": "1.8.17",
+ "@cubejs-backend/schema-compiler": "1.8.17",With it, Generated by Claude Code |
buildJoinTreeForRoot deduplicated the joins of every join tree with R.uniq, which deep-compares join definitions, including their SQL functions (Ramda stringifies a function to compare it). Every edge is one object per from-to pair, so equal edges are the same object and a Set gives the same result. On a 350-cube model with 330 rollups that join four cubes each, this was 75% of the refresh scheduler's first pass after a compile, which runs synchronously and blocks the refresh worker: 35s -> 8s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TgekqAsnzjzDLeNzsQJE5Q
eeead5e to
b4baf8a
Compare
|
Claude finished @paveltiunov's task in 40s —— View job LGTM: no issues found (0 high, 0 medium, 0 low) Review details
CorrectnessThe
PerformanceThis removes Ramda's deep Testing / docs
Review threadsThe listing returned 0 of my own threads (no prior threads), so I resolved 0 and re-affirmed 0. CIThe |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #12560 +/- ##
=======================================
Coverage 65.73% 65.73%
=======================================
Files 255 255
Lines 21507 21507
Branches 5157 5157
=======================================
Hits 14137 14137
Misses 6601 6601
Partials 769 769
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Check List
Issue Reference this PR resolves
Part of CORE-1177 (Pre-Aggregations page and refresh worker performance on large models).
Description of Changes Made
JoinGraph.buildJoinTreeForRootdeduplicated the joins of every join tree withR.uniq.R.uniqdeep-compares the join edges, including their join definitions and SQL functions, and Ramda stringifies a function to compare it. Every edge comes fromthis.edges[\${from}-${to}`], one object per from-to pair with distinctfrom/to, so two edges are deep-equal only when they are the same object. Deduplicating with aSet` gives the same result, in the same first-occurrence order, without the deep comparison.Why it matters: the refresh scheduler plans every scheduled pre-aggregation synchronously after each compile, and on large models this deep comparison dominated that pass. Until it finishes the refresh worker answers nothing else, including the Pre-Aggregations page's
/cubejs-system/v1/pre-aggregations/partitionsrequests.Measurements (generated model: 350 cubes of ~40 members, each joined to three neighbours, 330 year-partitioned rollups pulling measures from four joined cubes; the scheduler's per-pre-aggregation
getSql(..., { preAggregationsOnly: true })replayed for all of them):In a CPU profile of that pass,
buildJoinTreeForRootwas 75% of the time, almost all of it Ramdaequals/_functionName. Running the refresh worker on the same model,/livezstalled for up to 27 s with scheduled refresh on and under 50 ms with it off.What remains is Tesseract planning: one native call to match each pre-aggregation and one to build its load SQL.
Testing
cubejs-schema-compilerunit suite: 62 suites, 1,257 tests pass. The join-path suites (join-alias-paths,duplicate-cube-joins,join-hints-cache-pollution,rollup-join-time-dimension-hints) cover the join trees this builds.Generated by Claude Code