Repository navigation
perf: accelerate unordered primary-key IN filtering - #32082
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? |
|
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: cb3d95e782cb25a159e3293d0f804af3b7fc2c04
Assessment: approve
No actionable findings. Bounded membership reuse preserves selection semantics and ownership, with measured gains that justify its allocation cost.
Model: gpt-6.1-sol / max
Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0
Validation:
-
Both owning packages passed normal and race tests with no skips, using matching native prerequisites built in a writable frozen-head copy.
-
TestUnsortedPKInSearchConcurrentReuse passed 100 race repetitions.
-
Construction-inclusive benchmark: 1,000 keys across 124 blocks improved from 55.0 ms to 6.82 ms median against the exact-base factory control. Allocation at the cap was approximately 0.56 MiB.
-
Scope, both discussion keys, source identity and command/log/exit receipts reconciled in validation-summary.json. Final audit passed: checks/1793695068566952095-3.json. Source remained unchanged.
Limitations:
-
Frozen CI reports 6 successes, 13 skipped, 5 in progress and 2 neutral checks; pending checks are not passes.
-
Measurements are local component benchmarks. SQL, cold-storage, multi-CN performance and retained-heap peaks were not independently measured. The linked planner-selection issue remains open.
|
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: f7f80a9a86696550ee6621ffd36ecf544b3dfa2c
Assessment: approve
No actionable findings. The guards and float fallback preserve correctness; measured reuse gains justify the bounded allocation and fallback costs.
Model: gpt-6.1-sol / max
Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0
Validation:
-
Current readutil normal and race suites passed without skips; the mixed-size concurrent-reuse test passed 100 race repetitions.
-
Unchanged vector normal/race evidence was reused after verifying relevant source, dependency and build inputs.
-
Construction-inclusive partial-block benchmark improved from 8.02 ms to 1.68 ms median against the original production-code control.
-
All four discussion keys and command/source/log/exit receipts reconciled in validation-summary.json. Final audit passed: checks/1793698601107448260-3.json. Source remained unchanged.
Limitations:
-
Local samples showed about 13% overhead below the row threshold and 60–75 ns extra for tiny/constant inputs; this is not an all-input speedup.
-
Frozen CI has 5 checks in progress: 6 success, 13 skipped and 2 neutral.
-
SQL, cold-storage, multi-CN performance and retained-heap peaks were not independently measured. The linked planner-selection issue remains open.
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed all four changed files and traced filter validation/ownership through ConstructBlockPKFilter and the IN type dispatch. No actionable finding. The immutable per-closure set is capped at 16,384 candidates, initialized once only for sufficiently large physical vectors, and leaves sorted-block, unnormalized, short-list and float paths unchanged. Equality/custom-comparator argument order, constant-vector physical length, partially filled blocks, concurrent first publication, and key/row thresholds have distinct regression coverage. Reused the recorded normal/race package and SQL differential/benchmark evidence plus successful current-head CI; no new local test run. The disclosed per-reader/disjunct heap multiplier and bounded one-shot construction regression are accepted scope/performance tradeoffs, not a claim to fix planner index admission.
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
|
mo-bot review · Commit: New discussion was assessed; the previous review remains unchanged. |
|
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: 49a89f469a1fa9cf5ae1330d1218059a5a79d201
Assessment: approve
No actionable findings. Reusing the existing sorted search after a per-vector order check avoids unnecessary maps while preserving bounded lazy hashing, selection semantics and ownership. The broader planner issue #32015 remains open.
Model: gpt-6.1-sol / max
Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0
Validation:
-
Reviewed the complete four-file delta, affected consumers and linked issue. All nine discussion items are accounted for; final source audit passed and both checkouts remain clean.
-
Vector and readutil packages passed normal and race tests on Go 1.27.1 with no skips: checks/1793728365091308556-3.json and checks/1793728603510262384-3.json.
-
Concurrent-reuse test passed 100 race repetitions: checks/1793728649349807934-3.json. Both focused blockio consumer tests passed: checks/1793728742409274211-3.json.
-
Native prerequisites were built from the frozen head and provenance verified. Commands, exits and retained logs are reconciled in validation-summary.json.
Limitations:
-
Supplied SQL and performance measurements were assessed but not independently rerun; relevant frozen CI contexts remained pending.
-
Cold remote I/O, multi-CN performance and peak memory remain unverified. Bounded per-filter memory and one-shot overhead are accepted tradeoffs.
What type of PR is this?
Which issue(s) this PR fixes:
Related to #32015. This improves execution; the automatic index-versus-scan selection issue remains open.
What this PR does / why we need it:
Unordered primary-key backfill may search a candidate list for every base-table row. For normalized integer-backed IN lists with 64–16,384 keys, use a bounded, lazily built and reusable membership set only when a physical vector has at least
max(BlockMaxRows/2, ceil(candidateCount/2))values. Before using that set, check the physical row order: a vector verified entirely ordered reuses the existing sorted search, while the first inversion uses the hash path. If every eligible vector is ordered, the map is never built. The sorted and unordered callbacks share the same immutable candidate search. Unnormalized integer lists and lists of at most four keys use exact linear search; other normalized integer lists outside the hash guard use binary search. Floats use linear or binary search according to candidate normalization and size. No SQL-specific rule, planner admission change, or cross-block order cache is introduced.The shared vector factory also chooses equality versus custom-comparator search once instead of testing comparator mode on each comparison.
Validation:
pkg/vm/engine/readutilnormal and race suites, a 100-repeat concurrent-publication race test, 15 integer/bit/time/enum dispatches, ordered/first/middle/last inversion, empty/no-hit and 64/65 boundaries, unnormalized input, and float controls passed. Focused blockio consumer tests passed normally and under race. Incremental vet and configured lint passed; the unchangedpkg/container/vectorpackage passed normal/race and SCA earlier in this PR.(id, payload)rowsets matching an independent oracle; prepared execution, workspace inserts and rollback passed. For the point predicate, fake-PK AUTO medians across the two baseline runs were 2.950/2.935 ms versus 1.571/1.679 ms in the two final runs; real-PK AUTO was 1.668/1.754 versus 1.607/1.705 ms, and clustered AUTO 0.796/0.780 versus 0.779/0.790 ms. These are local measurements, not a speed guarantee.A last-pair inversion necessarily adds an order scan before falling back to the hash. One short synthetic sample was 20.5% slower across 16 blocks; a longer local repeat did not reproduce it consistently. Earlier full-PR component tests also observed an approximately 19% one-shot cost at the candidate cap against a prior binary-only implementation, with repeated probes benefiting. Results can vary with key distribution, block reuse, concurrency and hardware. Cold remote storage and multi-CN performance have not been verified. Remote CI on the updated head is pending.