Repository navigation
perf(vector): preserve bulk marshal for selected varlen - #28724
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed 119c47e against main d44f033. No concrete blocker found.
This is a focused restoration of an existing serialization fast-path invariant, not a new storage/wire contract. I read all three changed files and traced unionT (both int32 and int64 selections), varlena append/growth, backing ownership, marshal planning and null normalization. The proof is captured only for an already owned, disjoint destination and restored only after successful non-const materialization. Repeated/out-of-order source rows receive fresh appended ranges; existing aliases/borrowed destinations cannot acquire the proof, const broadcasts return without restoring it, and copy/allocation failure leaves the conservative path. Empty selections and fixed-width behavior remain unchanged. Serialization retains existing size checks and stale NULL-descriptor normalization; there is no added shared state, worker or synchronization dependency.
The new regression checks repeated selections, distinct offsets, NULL/inline payloads, actual bulk-path selection and decoded values; the const case explicitly verifies canonical fallback. The benchmark measures the selected-vector marshal path rather than charging fixture construction to the timed loop. Additional borrowed-destination or repeated-append cases would be useful supplementary coverage, not blockers for the guarded change.
Evidence/limits: source review plus the author's reported vector/batch/shuffle/hashbuild package checks, focused selection tests and five benchmark samples. I did not independently execute native tests or reproduce the reported benchmark. The narrow marshal cost reduction is supported by the eliminated canonical scan/metadata allocations; this review does not establish that the full billion-row workload in #28659 is resolved. Head/base were rechecked immediately before submission; source worktree left unchanged.
Merge Queue Status
This pull request spent 1 minute 30 seconds in the queue, with no time running CI. Waiting for any of
All conditions
ReasonPull request #28724 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
…#28724) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#28659 ## What this PR does / why we need it: `UnionInt32` materializes every selected non-const varlen value into a fresh destination-area range, but it conservatively cleared the destination `areaDisjoint` proof. Since matrixorigin#28145, that makes shuffle and hash-build spill batches use canonical varlen serialization, which scans every descriptor, builds per-row canonical metadata, and emits descriptors individually. Preserve the disjoint-area proof only when the destination was already owned and disjoint. Const selections and borrowed or aliased destinations remain on the canonical path. For an 8192-row selected varchar vector, `BenchmarkMarshalBinarySelectedVarlena` changes from about 2.06 ms/op, 455 KB/op, and 8233 allocs/op to about 35 us/op, 20 B/op, and 6 allocs/op. Validation: - `go test ./pkg/container/vector ./pkg/container/batch ./pkg/sql/colexec/shuffle ./pkg/sql/colexec/hashbuild -count=1` - `go test ./pkg/container/vector -run "^TestUnionSelection" -count=1` - `go test ./pkg/container/vector -run "^$" -bench "^BenchmarkMarshalBinarySelectedVarlena$" -benchmem -benchtime=2s -count=5` Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…#28724) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#28659 ## What this PR does / why we need it: `UnionInt32` materializes every selected non-const varlen value into a fresh destination-area range, but it conservatively cleared the destination `areaDisjoint` proof. Since matrixorigin#28145, that makes shuffle and hash-build spill batches use canonical varlen serialization, which scans every descriptor, builds per-row canonical metadata, and emits descriptors individually. Preserve the disjoint-area proof only when the destination was already owned and disjoint. Const selections and borrowed or aliased destinations remain on the canonical path. For an 8192-row selected varchar vector, `BenchmarkMarshalBinarySelectedVarlena` changes from about 2.06 ms/op, 455 KB/op, and 8233 allocs/op to about 35 us/op, 20 B/op, and 6 allocs/op. Validation: - `go test ./pkg/container/vector ./pkg/container/batch ./pkg/sql/colexec/shuffle ./pkg/sql/colexec/hashbuild -count=1` - `go test ./pkg/container/vector -run "^TestUnionSelection" -count=1` - `go test ./pkg/container/vector -run "^$" -bench "^BenchmarkMarshalBinarySelectedVarlena$" -benchmem -benchtime=2s -count=5` Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…#28724) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#28659 ## What this PR does / why we need it: `UnionInt32` materializes every selected non-const varlen value into a fresh destination-area range, but it conservatively cleared the destination `areaDisjoint` proof. Since matrixorigin#28145, that makes shuffle and hash-build spill batches use canonical varlen serialization, which scans every descriptor, builds per-row canonical metadata, and emits descriptors individually. Preserve the disjoint-area proof only when the destination was already owned and disjoint. Const selections and borrowed or aliased destinations remain on the canonical path. For an 8192-row selected varchar vector, `BenchmarkMarshalBinarySelectedVarlena` changes from about 2.06 ms/op, 455 KB/op, and 8233 allocs/op to about 35 us/op, 20 B/op, and 6 allocs/op. Validation: - `go test ./pkg/container/vector ./pkg/container/batch ./pkg/sql/colexec/shuffle ./pkg/sql/colexec/hashbuild -count=1` - `go test ./pkg/container/vector -run "^TestUnionSelection" -count=1` - `go test ./pkg/container/vector -run "^$" -bench "^BenchmarkMarshalBinarySelectedVarlena$" -benchmem -benchtime=2s -count=5` Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #28659
What this PR does / why we need it:
UnionInt32materializes every selected non-const varlen value into a fresh destination-area range, but it conservatively cleared the destinationareaDisjointproof. Since #28145, that makes shuffle and hash-build spill batches use canonical varlen serialization, which scans every descriptor, builds per-row canonical metadata, and emits descriptors individually.Preserve the disjoint-area proof only when the destination was already owned and disjoint. Const selections and borrowed or aliased destinations remain on the canonical path.
For an 8192-row selected varchar vector,
BenchmarkMarshalBinarySelectedVarlenachanges from about 2.06 ms/op, 455 KB/op, and 8233 allocs/op to about 35 us/op, 20 B/op, and 6 allocs/op.Validation:
go test ./pkg/container/vector ./pkg/container/batch ./pkg/sql/colexec/shuffle ./pkg/sql/colexec/hashbuild -count=1go test ./pkg/container/vector -run "^TestUnionSelection" -count=1go test ./pkg/container/vector -run "^$" -bench "^BenchmarkMarshalBinarySelectedVarlena$" -benchmem -benchtime=2s -count=5