Repository navigation
[4.2-dev] perf: backport COUNT(DISTINCT) optimizations (#27693, #28431) - #32646
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
This pull request is merged. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: a717091e1d8437911f8e90a17463d18ea668ee5a
Assessment: approve
The backport extends the existing aggregate, serialization and shuffle owners coherently. Exact key/log/count state, cleanup and legacy encoding are preserved; the fixed index is justified by the reported component gains while the skiplist retains unsupported and ordered cases. No actionable findings remain within the documented 4.2 memory and spill limits.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Reviewed the complete 17-file delta, versioned design and design-phase adjustment, all discussion entries, linked issue context, and producer/consumer/error/cleanup paths. Verified the reported binary diff hash, clean frozen source, gofmt and git diff --check.
-
Private-runtime preflight passed. Qualified native inputs and artifacts, verified task caches and Go 1.26.4 Linux amd64/v1 CGO environment, and reconciled receipts with retained logs.
-
Arena and aggregate packages passed under -race: 16 and 258 test roots respectively, with no skips. All 14 new arena/aggregate behavioral roots passed 100 adaptive race repetitions each, with no failures or race reports.
-
TestDistinctBackportMultiCN passed on the real three-CN fixture: executed multi-CN shuffle, exact no-shuffle result equality, DOP-one, NULL/duplicate/tuple, outer-join NULL-group and non-COUNT controls.
-
Reused the author's exact-head normal/race planner, compiler and Group results, configured lint and paired component benchmark reports within their stated scope.
Limitations:
-
Frozen build, UT, SCA, coverage and Iceberg checks were pending; these are not passes.
-
Broader planner/compiler/Group runs, multi-CN race execution, lint and performance measurements were reported without raw local_validation artifacts and were not repeated locally. The warm executor benchmark does not establish production or full ClickBench Q10 latency.
-
This backport retains the existing DISTINCT-spill limitation and operator-pool/shared-global memory caps. Parallel states plus a live merge destination can increase peak memory; no per-query or tenant-isolated memory bound is added.
|
mo-bot review · Commit: "interrupted" |
What type of PR is this?
Which issue(s) this PR fixes:
Related to #27672.
Backports #27693 (
dfef35f7dd94de507d40dd18082b64e7f4b84e40) and #28431 (98171c28dbeb7ad1291ce9b0eb5beff7a84cbc32) together to4.2-dev.What this PR does / why we need it:
On 4.2, mixed aggregates containing COUNT(DISTINCT) are forced through one worker/CN, while fixed-width DISTINCT values use ordered skiplist lookups and repeated arena rebuilding. This adapts the two source optimizations to the existing 4.2 aggregate owners:
(group, value)index and direct merge with MPool-backed arrays, finite probing, checked growth, coherent partial-error state, and deterministic cleanup. Keep the existing aggregate wire format and legacy representation fallback.The versioned design records the ownership, compatibility, failure and resource contracts. The design-only phase was approved at
98387de8fc82d834188df5d42eb84d057cedeeccbefore implementation. Final implementation:a717091e1d8437911f8e90a17463d18ea668ee5aagainst basedb0a7e76881bba94c2a86504ed8e3b2463fc6835.Validation: Linux amd64, Go 1.26.4, CGO,
GOAMD64=v1,GOMAXPROCS=4; native libraries built in this worktree. Repositorymo-cgo-testwrapper,-mod=readonly -p=2 -parallel=2 -short -tags=matrixone_test -count=1:-race; the planner retains three existing unrelated skipped subtests. The final compiler runs selected 1,514 tests/subtests each with no skips.TestDistinctBackportMultiCNpassed normally and under-race: exact optimized/no-shuffle result equality, executed shuffle on multiple CNs, DOP 1, duplicate/NULL/tuple and non-COUNT controls, and LEFT JOIN NULL-group correctness.git diff --checkpassed..codexin GOTMPDIR, which the existing file enumerator skips. Both full compiler modes passed after setting TMPDIR and GOTMPDIR to a nonhidden disk directory; no tests were skipped or unrelated source changed.Paired local executor benchmark, identical 65,536 values/128 groups,
-benchmem -benchtime=3x -count=3(median):This is a small warm microbenchmark on a shared host, not a production SQL latency claim. Go allocations fell from roughly 65–68k to 17 per operation; benchmem excludes MPool off-heap memory.
Branch limits: DISTINCT spill and later-main aggregate preflight/accounting are outside this backport. Existing operator-pool/shared-global allocation limits remain authoritative; parallel non-shuffle states and a live merge destination can increase peak memory. No per-query or tenant-isolated memory bound is added. Upgrade remains a full shutdown.
Review:
gpt-6.1-terrawithmaxreasoning approved the design before implementation and the complete committed change ata717091e1d8437911f8e90a17463d18ea668ee5abefore push. Final review: PASS, no unresolved material blocker. Base-to-head binary diff SHA-256:90694283dab3dd1847d4a7e13d095027f5dc14934c64b782899896ed4f4b1c22.GitHub CI has not been verified; local validation does not imply CI success.