Repository navigation
perf(exec): consume selected scan batches through expressions and operators - #32492
Conversation
This comment has been minimized.
This comment has been minimized.
Use already-owned capacity for plain 4-byte and 8-byte selected appends while preserving alias, validity and provenance handling. Reject constant, nullable, metadata-bearing and unallocated destinations before the specialized checks. Dispatch preflighted bulk appends directly to their flat or dictionary implementation without changing the ordinary public path.
Traverse at most two ascending bucket ranges per input and save a visit cursor for blocked retries. Preserve explicit whole-bucket destinations and existing ready-credit, ownership and copying contracts. Add deterministic tests for resumed writes before and after wrap and closed consumers.
Return immediately only when all frame owners and observation counters are empty. Preserve existing cleanup for initialized scratch, partial predicate discovery and account or width changes. Avoid repeatedly resetting unused dictionary metadata on flat query paths.
Final comparison and Q7 allocation attributionNormal comparison: main Protocol: local 32 logical CPUs, 16 GiB CN shared cache, 48 GiB application/aggregate/join budgets, parent 52 GiB, GOGC=100 and swap disabled. One process per arm/configuration, one excluded cold full22 followed by five warm full22. Execute and drain SQL; no benchmark-time schema/data/result verification. No kernel/page/cache-policy changes. All six normal and six accounting configurations completed under the existing interference/spill/swap/OOM guards.
Positive observations remain visible. SF100 physical reads were 798.950 vs 849.394 GiB; host huge-page backing/fallback diagnostics also differ strongly. These support environmental attribution but do not prove every slower query is unrelated to the PR. Warm suites in one process do not provide independent-process confidence bounds. Q6 SF10 has exactly 70,893 additional counted bytes: 536 explicit-copy bytes, 69,813 indexed-store bytes and 544 newly measured frame-pointer bytes. This is about 0.0146% of its counted traffic and remains real metadata work. The original full-suite Q7 SF100 Go-plus-offheap allocation observation is +6.24%; it is preserved below. Focused Q7 investigationSame pinned sources; one SF100 disk process per arm, one excluded cold full-suite initialization followed by five Q7-only native callsite recordings. This diagnostic has a different query context and additional probe overhead; its timing/Go allocation totals do not replace normal acceptance measurements. All ten traced native byte/request totals exactly reconcile with MPool counters.
This establishes batching-sensitive allocation traffic and finds no increased allocation cost at the matched-input buffering boundary. It does not reconstruct the original full-suite +6.24% result or prove that producer scheduling can never bias batching. No additional production optimization is included from that aggregate observation alone. All temporary diagnostic databases/ramdisks and engines have been cleaned up; exact profiles, source pins and binaries are retained. The requester instructed “wrap up the PR” after reviewing these findings, accepting the fixed Q6 overhead and remaining Q7 batching/context uncertainty for review. The original positive observations remain visible; this is not an unqualified zero-regression claim. Published head All 22 normal query results, including CPU and retired instructionsMeasured on one local process per arm/configuration; first full suite excluded, five full warm suites profiled. Wall times are per-query medians and Total is their sum. Counters are user-space retired instructions; CPU/I/O/memory use the complete application cgroup. No benchmark-time data/result verification. SF10 memory
Slower medians requiring investigation: Q3, Q5, Q6, Q8, Q9, Q15, Q17, Q20, Q21. SF10 disk
Slower medians requiring investigation: Q3, Q5, Q6, Q8, Q9, Q14, Q17, Q20. SF100 disk
Slower medians requiring investigation: Q1, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q12, Q14, Q15, Q16, Q17, Q20, Q21. All 22 allocation/copy observations, with every positive retainedPer-query allocation/copy observations against mainOne excluded cold full22 and five warm full22 per instrumented process. sf10-memory
sf10-disk
sf100-disk
No automatic acceptance decision; timing, allocation and copy gates require review. |
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? |
|
Queue requested — the merge queue status continues in this comment ↓. |
|
Published fix Fixed the changed-code coverage failure on
Owning batch/shuffle tests, merged CSV-parser tests, incremental static checks and the final complete pre-push gate passed. Latest main is merged. This correction changes no active production path, so the previously reported benchmark observations and their measured heads remain unchanged. |
✅ Merged into
|
|
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: 0a9739b99fa83fd6b48ab03adbefde90fd16574b
Assessment: approve
The change coherently extends existing leases, allocation accounts, VM boundaries and shuffle buffers with bounded per-lane reuse and owned flat fallbacks. No actionable defects remain; the documented Q6 overhead and Q7 uncertainty are accepted design tradeoffs.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Reviewed all 139 changed files, all 13 discussion entries and both linked issues; saved change-map.json and discussion-assessment.json.
-
Reused frozen-head CI successes: UT, SCA, coverage, and PROXY/PESSIMISTIC multi-CN BVT.
-
Private /tmp and loopback preflight passed. Fresh Go1.27.1 bufferlease race tests passed using test-exec; receipt checks/1794766293798597259-2.json.
-
Source audit passed: clean checkout, diff checks, formatting of 135 Go files, complete discussion coverage, and changed production files identical to measured candidate 866816d; receipt checks/1794766870039411044-2.json.
-
validation-evidence.json correlates all local checks with receipts and retained stdout/stderr.
Limitations:
-
Performance observations reuse supplied source-pinned reports; benchmarks and raw profiles were not independently replayed.
-
Broad functional and multi-CN validation relies on supplied CI; local execution covered the bufferlease race package.
|
Verified follow-up fixed by this merged consumer migration: #32586. The issue's original flat/dictionary GROUP BY reproducer now passes baseline, forced spill/retry and secondary-failure cleanup; selected/repeated/NULL controls also pass on main-identical grouping/hash/vector code. Exact source pins, cases and results. This comment records the actual fixing PR relationship for issue closure; it adds no new performance claim. |
What type of PR is this?
Which issue(s) this PR fixes:
Closes #32385
Closes #32386
What this PR does / why we need it:
Retain immutable selected scan/filter batches across supported consumer edges, so expressions, key encoders, aggregate updates and payload gathers can read logical rows without first constructing a complete flat batch. Preserve row order, repeated rows, NULL/grouping metadata and physical allocation ownership.
Add execution-owned scratch that lazily materializes a required contiguous input column once per batch/selection domain and shares it across sibling expressions. Keep masked evaluation local to its active rows and retain existing native/SIMD decimal kernels. Extend audited comparison, membership, BETWEEN, string and NULL-predicate paths to logical reads while preserving existing flat/constant fast paths.
Evaluate each predicate against only its referenced selected columns, reusing frozen backing within that batch and publishing the final output once. Resolve typed primitive reads once outside the selected row loop while retaining wrapper conversions when necessary.
Retain privately validated cached columns as read-only flat sources with full physical pin accounting, avoiding an intermediate identity dictionary. Publish one surviving-row selection, reuse private snapshot headers and row-map scratch after final borrower release, and encode eligible selected fixed-width hash keys through typed loops. Keep reusable owned buffers and the existing copy path when borrowing is unavailable.
Preserve sorted-range endpoint routing before per-row enumeration and use typed fixed-width selected bulk copies while retaining the original append preflight and metadata propagation.
Keep private normalization frames alongside pooled operators in the same allocation, outside repeated operator resets. Preserve zero-state cleanup, borrowed-input retirement and allocation-account ownership.
Support selected ingress in ordinary hash/range shuffle using the existing partition functions, accounted flat destination buffers and pending-write/cancellation protocol. Preserve whole-bucket forwarding through the existing lifetime contract; flat-only boundaries use one reusable owned normalization bank. Keep original reader workspace vectors across selected publication and return their original MPool backing only after the last immutable borrower releases it. Reuse retired private predicate/publication headers without a global pool. Retain explicit flat boundaries for unsupported modes and existing owned fallbacks when backing cannot be retained. This does not introduce dictionary partition/join output views or change SQL types, cache policy or wire formats.
Validation
eed0029c66, merged with authoritative main0d0413e804.Performance evidence
The final comparison and targeted Q7 allocation attribution are recorded in the final results comment. SF10 totals improve; SF100 wall-time and per-query allocation observations include the documented run-context variability. The update preserves all original positive observations and the fixed Q6 metadata overhead. It does not claim universal zero regression. The requester accepted the disclosed fixed Q6 metadata cost and remaining Q7 batching/context uncertainty for review. This does not establish universal zero regression or relax correctness, ownership or memory-limit checks.
Design
Versioned design and approved scope revisions.