Repository navigation
perf(fileservice): share scoped object-column decompression - #28413
Merged
XuPeng-SH merged 10 commits intoSep 8, 2026
Merged
Conversation
Define bounded read leases for overlapping object-column decompression, including admission, cancellation, close, and final-release ownership. Relate the performance work to matrixorigin#24097 and keep implementation gated on design review.
Reuse validated decompressed column data across overlapping scoped Top-K reads when memory-cache admission is unavailable. Keep compressed I/O and cache updates per read, and leave memory hits and unscoped readers on their existing paths. Bound sharing by backing bytes, live generations and participants. Preserve the concrete validated cache-data type, independent cancellation, bounded fallback and generation-safe final release. Protect active read and deferred cache-update lifetimes during file-service shutdown without waiting for Top-K consumers. Add fixed-cardinality metrics, deterministic ownership and failure-path tests, a persisted ObjectIO consumer test, and cache-pressure/control benchmarks.
Record the unchanged-index SQL comparison after the vector-membership planner merge, and clarify that borrowed decoded views must be consumed before the complete IOVector is released.
Store the opt-in descriptor inline and snapshot only the owned resources in IOVector.Release. This preserves stable codec identity and release ordering without allocating separate metadata or copying unused read inputs on the memory-hit path. Preallocate the key-isolation test results and record matched literal-main benchmarks: cache-hit and independent-key medians stay within 5%, while overlapping reads perform one decode instead of eight.
aunjgr
marked this pull request as ready for review
September 8, 2026 12:02
aunjgr
requested review from
LeftHandCold,
XuPeng-SH,
aptend and
fengttt
as code owners
September 8, 2026 12:02
3 of 7 tasks
XuPeng-SH
pushed a commit
that referenced
this pull request
Sep 8, 2026
## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [x] Documentation - [ ] Feature - [ ] Test and CI - [x] Code Refactoring ## Which issue(s) this PR fixes: Related to #24097, following #28413. This contributes to query-execution performance improvements without closing the umbrella issue. ## What this PR does / why we need it: Compute vector Top-K directly over eligible chunked object columns instead of reconstructing, concatenating and reserializing the entire column. Preserve existing decoded whole-column cache hits and the legacy, synthetic-column and unsorted-selection fallbacks. Use one incremental candidate accumulator across chunks while retaining the reader-wide distance heap, original selection ordinals, duplicates, non-finite behavior and distance bounds before heap admission. Read only selected payload ranges, validate directory and payload contracts, and keep each decoded view inside its complete IOVector lease before releasing it and advancing. Reuse scoped decompression sharing at chunk granularity without adding buffer recycling, allocator pools or write-format changes. Add tiny persisted fixtures for ranking, corruption, cancellation, sharing and Close, together with cache-pressure and compatibility benchmarks. ## Design and scope [Design and validation record](https://github.com/aunjgr/matrixone/blob/perf/chunk-native-topk/docs/design/chunk_native_topk.md). - `LoadColumnDataByTopN` keeps its signature and delegates to ObjectIO's scoped `ReadColumnTopN` entry point. - Streaming is limited to existing `Lz4Chunked` extents and nil/nondecreasing selections. Unsorted inputs keep their existing tie order through the old path. - Retain at most one decoded chunk plus its compressed buffer, the bounded directory and O(K) ranking state. Existing cache/sharing budgets remain independent. - No decoded-buffer recycling, writer rollout, data rewrite, new format/protocol, fused INCLUDE expansion or additional parallelism. - More cold range-read calls are a tradeoff; this is not a claim about remote-storage latency or legacy-file performance recovery. ## Validation - ObjectIO, ObjectIO/ioutil and persisted block-reader owning suites in normal mode; production `GOAMD64=v3 GOEXPERIMENT=simd` mode also tested. - Owning-package race checks, plus 100 repetitions of the exact concurrent sharing/Close test after its measured race duration. - Selection/tie/displacement, reader-wide seeded heap, all six vector representations, NULL/non-finite/range behavior, malformed directories and payloads, errors after earlier chunks, cancellation, Close, wide offsets and skipped unselected payloads. - Differential check against main's exact ranking function: 64 deterministic cases matched rows and distance bits. - Existing `vector_ivf_topk_consumers` BVT: **58/58 statements passed twice** in normal comparison mode, with database teardown verified after each run. - New chunk-reader statement coverage: **91.7% (100/109)**. - Static analysis passed with **0 issues**: package graph, MO lint, license checks and golangci-lint. ## Performance evidence Five matched samples, Go 1.26.4, Linux amd64, `GOAMD64=v3 GOEXPERIMENT=simd`, main `4b43f8c99b`. The control uses the unchanged whole-column read/converter and main's exact ranking function; the candidate uses chunk-native execution. | Scoped ObjectIO workload | Main elapsed/read | Candidate elapsed/read | |---|---:|---:| | Whole decoded-cache hit | 333.9 us | 308.9 us | | Legacy LZ4 under cache pressure | 649.0 us | 615.1 us | | Four chunks, all rows, disk cache warm | 5.923 ms | 1.234 ms | | Four chunks, selection in one chunk | 5.584 ms | 0.392 ms | | Four chunks, local store without disk cache | 6.524 ms | 2.397 ms | For the all-row pressure case, process CPU/read was **17.965 -> 1.242 ms** and Go allocation volume **61.4 MB -> 14.8 KB**. The largest returned decoded allocation was **16 MiB -> 4 MiB**; tests verify that the iterator holds at most one at a time. These are not total-process RSS measurements. The fixture uses 4,096 synthetic 768-dimensional vectors with four existing-format chunks, including LZ4 and raw payloads. Pressure cases pin an 8 MiB memory cache; the hot-cache control uses 64 MiB. All-row FileService.Read calls increase from one to six, while sparse selection reads only one payload. Call counters are logical calls, not network requests. **These are not SQL QPS or Wiki-10M results.** Both compatibility controls meet the 5% median regression gate. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 task done
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…igin#28413) ## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [x] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#24097 — query execution performance improvements, particularly decompression overhead and repeated allocation. This contributes to the umbrella issue without closing it. Related investigation: matrixorigin#27854. This PR is separate from matrixorigin#28002 and does not claim Wiki-10M performance recovery. ## What this PR does / why we need it: Reuse validated decompressed object-column data across overlapping scoped Top-K reads when memory-cache admission is unavailable. Keep compressed I/O and cache updates per read, and leave memory hits and unscoped readers on their existing paths. Bound sharing by decoded backing bytes, live generations and participants. Preserve the concrete validated cache-data type, independent cancellation, bounded fallback and generation-safe final release. Protect active reads and deferred cache updates during file-service shutdown without waiting for Top-K consumers. Add fixed-cardinality sharing metrics, deterministic ownership and failure-path tests, a persisted ObjectIO Top-K consumer test, and cache-pressure/control benchmarks. ## Design and scope The decompression-only design was approved before implementation; the code is included in this same PR. [Design, ownership model, limits and validation record](https://github.com/aunjgr/matrixone/blob/1849b408dd/docs/design/scoped_shared_column_decode.md). - Opt-in: single-column scoped `LoadColumnDataByTopN` reads only. - Limits: at most 64 MiB (also capped by initial cache capacity), 64 live generations, 128 participants per generation, and a 200 ms follower wait before independent fallback. - No idle result retention, background worker, storage-format change, or cross-CN sharing. - Fused INCLUDE reads, chunked Top-K execution, allocator buffer reuse, persistent-cache resizing and quantization are outside this change. ## Evidence and validation - Normal owning packages: FileService, ObjectIO, ObjectIO/ioutil, metrics/v2 and the block-reader consumer. - Race: FileService, ObjectIO and ObjectIO/ioutil; focused lifecycle tests individually repeated 100 times after measuring their race-mode duration. - Failure coverage: cancellation of either role, timeout, ordinary/partial-result errors, panic abandonment, oversized/rejected admission, stale-generation cleanup, final physical release, and Close during conversion or deferred cache update. - Actual disk-cache fixture: eight overlapping reads execute one decompression into the same backing allocation, with no object-store GET. ObjectIO tests preserve the validated-data marker and independent query vectors, selections and thresholds. - Five 3-second microbenchmark samples against literal main FileService source: overlapping batch **180.9 → 148.0 µs** and **8 → 1 decompressions**. Memory-hit median **693.8 → 699.7 ns** (+0.9%, no extra allocation count); independent-key batch **180.3 → 186.6 µs** (+3.5%). Both controls remain within the 5% median regression limit. The descriptor is stored inline to avoid per-read allocation, and Release snapshots only owned resources. - Synthetic SQL on merged main `f8a690cb21`, before the final metadata-allocation cleanup: 32,768 × 768-dimensional vectors, eight index objects, two CNs, concurrency 100, 32 MiB cache. Mean CPU/query **147.1 → 122.2 ms**, QPS **201.1 → 242.3**, decoded backing allocation **129.2 → 104.8 MB/query**, and decompressions **7.93 → 6.45/query**. Exact rows and distances matched. - Large-cache control: both modes performed zero decompressions; QPS differed by about 1%. Short high-QPS samples have noisy tails; no tail-latency recovery claim is made. SQL comparisons toggle only sharing off/on/on/off in one locally instrumented binary against the same index contents. All temporary measurement hooks are removed from this PR. These are synthetic mechanism measurements, **not Wiki-10M acceptance results**. No dataset was downloaded or remote benchmark dispatched. - Final shared-decompression statement coverage: **94.9% (186/196 statements)**. - Full pre-push gate passed: package graph, MO lint, license headers/dependencies and golangci-lint (**0 issues**). Local tooling uses Go 1.26.4 and `-buildvcs=false` because an unrelated empty `/tmp/.git` prevents VCS stamping; no repository source or SCA rule is changed for that workaround. - Newest authoritative main `3d46ea965a` is merged. Its final JSON_QUOTE update does not alter this feature's runtime or benchmark path. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…in#28434) ## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [x] Documentation - [ ] Feature - [ ] Test and CI - [x] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#24097, following matrixorigin#28413. This contributes to query-execution performance improvements without closing the umbrella issue. ## What this PR does / why we need it: Compute vector Top-K directly over eligible chunked object columns instead of reconstructing, concatenating and reserializing the entire column. Preserve existing decoded whole-column cache hits and the legacy, synthetic-column and unsorted-selection fallbacks. Use one incremental candidate accumulator across chunks while retaining the reader-wide distance heap, original selection ordinals, duplicates, non-finite behavior and distance bounds before heap admission. Read only selected payload ranges, validate directory and payload contracts, and keep each decoded view inside its complete IOVector lease before releasing it and advancing. Reuse scoped decompression sharing at chunk granularity without adding buffer recycling, allocator pools or write-format changes. Add tiny persisted fixtures for ranking, corruption, cancellation, sharing and Close, together with cache-pressure and compatibility benchmarks. ## Design and scope [Design and validation record](https://github.com/aunjgr/matrixone/blob/perf/chunk-native-topk/docs/design/chunk_native_topk.md). - `LoadColumnDataByTopN` keeps its signature and delegates to ObjectIO's scoped `ReadColumnTopN` entry point. - Streaming is limited to existing `Lz4Chunked` extents and nil/nondecreasing selections. Unsorted inputs keep their existing tie order through the old path. - Retain at most one decoded chunk plus its compressed buffer, the bounded directory and O(K) ranking state. Existing cache/sharing budgets remain independent. - No decoded-buffer recycling, writer rollout, data rewrite, new format/protocol, fused INCLUDE expansion or additional parallelism. - More cold range-read calls are a tradeoff; this is not a claim about remote-storage latency or legacy-file performance recovery. ## Validation - ObjectIO, ObjectIO/ioutil and persisted block-reader owning suites in normal mode; production `GOAMD64=v3 GOEXPERIMENT=simd` mode also tested. - Owning-package race checks, plus 100 repetitions of the exact concurrent sharing/Close test after its measured race duration. - Selection/tie/displacement, reader-wide seeded heap, all six vector representations, NULL/non-finite/range behavior, malformed directories and payloads, errors after earlier chunks, cancellation, Close, wide offsets and skipped unselected payloads. - Differential check against main's exact ranking function: 64 deterministic cases matched rows and distance bits. - Existing `vector_ivf_topk_consumers` BVT: **58/58 statements passed twice** in normal comparison mode, with database teardown verified after each run. - New chunk-reader statement coverage: **91.7% (100/109)**. - Static analysis passed with **0 issues**: package graph, MO lint, license checks and golangci-lint. ## Performance evidence Five matched samples, Go 1.26.4, Linux amd64, `GOAMD64=v3 GOEXPERIMENT=simd`, main `4b43f8c99b`. The control uses the unchanged whole-column read/converter and main's exact ranking function; the candidate uses chunk-native execution. | Scoped ObjectIO workload | Main elapsed/read | Candidate elapsed/read | |---|---:|---:| | Whole decoded-cache hit | 333.9 us | 308.9 us | | Legacy LZ4 under cache pressure | 649.0 us | 615.1 us | | Four chunks, all rows, disk cache warm | 5.923 ms | 1.234 ms | | Four chunks, selection in one chunk | 5.584 ms | 0.392 ms | | Four chunks, local store without disk cache | 6.524 ms | 2.397 ms | For the all-row pressure case, process CPU/read was **17.965 -> 1.242 ms** and Go allocation volume **61.4 MB -> 14.8 KB**. The largest returned decoded allocation was **16 MiB -> 4 MiB**; tests verify that the iterator holds at most one at a time. These are not total-process RSS measurements. The fixture uses 4,096 synthetic 768-dimensional vectors with four existing-format chunks, including LZ4 and raw payloads. Pressure cases pin an 8 MiB memory cache; the hot-cache control uses 64 MiB. All-row FileService.Read calls increase from one to six, while sparse selection reads only one payload. Call counters are logical calls, not network requests. **These are not SQL QPS or Wiki-10M results.** Both compatibility controls meet the 5% median regression gate. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…igin#28413) ## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [x] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#24097 — query execution performance improvements, particularly decompression overhead and repeated allocation. This contributes to the umbrella issue without closing it. Related investigation: matrixorigin#27854. This PR is separate from matrixorigin#28002 and does not claim Wiki-10M performance recovery. ## What this PR does / why we need it: Reuse validated decompressed object-column data across overlapping scoped Top-K reads when memory-cache admission is unavailable. Keep compressed I/O and cache updates per read, and leave memory hits and unscoped readers on their existing paths. Bound sharing by decoded backing bytes, live generations and participants. Preserve the concrete validated cache-data type, independent cancellation, bounded fallback and generation-safe final release. Protect active reads and deferred cache updates during file-service shutdown without waiting for Top-K consumers. Add fixed-cardinality sharing metrics, deterministic ownership and failure-path tests, a persisted ObjectIO Top-K consumer test, and cache-pressure/control benchmarks. ## Design and scope The decompression-only design was approved before implementation; the code is included in this same PR. [Design, ownership model, limits and validation record](https://github.com/aunjgr/matrixone/blob/1849b408dd/docs/design/scoped_shared_column_decode.md). - Opt-in: single-column scoped `LoadColumnDataByTopN` reads only. - Limits: at most 64 MiB (also capped by initial cache capacity), 64 live generations, 128 participants per generation, and a 200 ms follower wait before independent fallback. - No idle result retention, background worker, storage-format change, or cross-CN sharing. - Fused INCLUDE reads, chunked Top-K execution, allocator buffer reuse, persistent-cache resizing and quantization are outside this change. ## Evidence and validation - Normal owning packages: FileService, ObjectIO, ObjectIO/ioutil, metrics/v2 and the block-reader consumer. - Race: FileService, ObjectIO and ObjectIO/ioutil; focused lifecycle tests individually repeated 100 times after measuring their race-mode duration. - Failure coverage: cancellation of either role, timeout, ordinary/partial-result errors, panic abandonment, oversized/rejected admission, stale-generation cleanup, final physical release, and Close during conversion or deferred cache update. - Actual disk-cache fixture: eight overlapping reads execute one decompression into the same backing allocation, with no object-store GET. ObjectIO tests preserve the validated-data marker and independent query vectors, selections and thresholds. - Five 3-second microbenchmark samples against literal main FileService source: overlapping batch **180.9 → 148.0 µs** and **8 → 1 decompressions**. Memory-hit median **693.8 → 699.7 ns** (+0.9%, no extra allocation count); independent-key batch **180.3 → 186.6 µs** (+3.5%). Both controls remain within the 5% median regression limit. The descriptor is stored inline to avoid per-read allocation, and Release snapshots only owned resources. - Synthetic SQL on merged main `f8a690cb21`, before the final metadata-allocation cleanup: 32,768 × 768-dimensional vectors, eight index objects, two CNs, concurrency 100, 32 MiB cache. Mean CPU/query **147.1 → 122.2 ms**, QPS **201.1 → 242.3**, decoded backing allocation **129.2 → 104.8 MB/query**, and decompressions **7.93 → 6.45/query**. Exact rows and distances matched. - Large-cache control: both modes performed zero decompressions; QPS differed by about 1%. Short high-QPS samples have noisy tails; no tail-latency recovery claim is made. SQL comparisons toggle only sharing off/on/on/off in one locally instrumented binary against the same index contents. All temporary measurement hooks are removed from this PR. These are synthetic mechanism measurements, **not Wiki-10M acceptance results**. No dataset was downloaded or remote benchmark dispatched. - Final shared-decompression statement coverage: **94.9% (186/196 statements)**. - Full pre-push gate passed: package graph, MO lint, license headers/dependencies and golangci-lint (**0 issues**). Local tooling uses Go 1.26.4 and `-buildvcs=false` because an unrelated empty `/tmp/.git` prevents VCS stamping; no repository source or SCA rule is changed for that workaround. - Newest authoritative main `3d46ea965a` is merged. Its final JSON_QUOTE update does not alter this feature's runtime or benchmark path. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…in#28434) ## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [x] Documentation - [ ] Feature - [ ] Test and CI - [x] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#24097, following matrixorigin#28413. This contributes to query-execution performance improvements without closing the umbrella issue. ## What this PR does / why we need it: Compute vector Top-K directly over eligible chunked object columns instead of reconstructing, concatenating and reserializing the entire column. Preserve existing decoded whole-column cache hits and the legacy, synthetic-column and unsorted-selection fallbacks. Use one incremental candidate accumulator across chunks while retaining the reader-wide distance heap, original selection ordinals, duplicates, non-finite behavior and distance bounds before heap admission. Read only selected payload ranges, validate directory and payload contracts, and keep each decoded view inside its complete IOVector lease before releasing it and advancing. Reuse scoped decompression sharing at chunk granularity without adding buffer recycling, allocator pools or write-format changes. Add tiny persisted fixtures for ranking, corruption, cancellation, sharing and Close, together with cache-pressure and compatibility benchmarks. ## Design and scope [Design and validation record](https://github.com/aunjgr/matrixone/blob/perf/chunk-native-topk/docs/design/chunk_native_topk.md). - `LoadColumnDataByTopN` keeps its signature and delegates to ObjectIO's scoped `ReadColumnTopN` entry point. - Streaming is limited to existing `Lz4Chunked` extents and nil/nondecreasing selections. Unsorted inputs keep their existing tie order through the old path. - Retain at most one decoded chunk plus its compressed buffer, the bounded directory and O(K) ranking state. Existing cache/sharing budgets remain independent. - No decoded-buffer recycling, writer rollout, data rewrite, new format/protocol, fused INCLUDE expansion or additional parallelism. - More cold range-read calls are a tradeoff; this is not a claim about remote-storage latency or legacy-file performance recovery. ## Validation - ObjectIO, ObjectIO/ioutil and persisted block-reader owning suites in normal mode; production `GOAMD64=v3 GOEXPERIMENT=simd` mode also tested. - Owning-package race checks, plus 100 repetitions of the exact concurrent sharing/Close test after its measured race duration. - Selection/tie/displacement, reader-wide seeded heap, all six vector representations, NULL/non-finite/range behavior, malformed directories and payloads, errors after earlier chunks, cancellation, Close, wide offsets and skipped unselected payloads. - Differential check against main's exact ranking function: 64 deterministic cases matched rows and distance bits. - Existing `vector_ivf_topk_consumers` BVT: **58/58 statements passed twice** in normal comparison mode, with database teardown verified after each run. - New chunk-reader statement coverage: **91.7% (100/109)**. - Static analysis passed with **0 issues**: package graph, MO lint, license checks and golangci-lint. ## Performance evidence Five matched samples, Go 1.26.4, Linux amd64, `GOAMD64=v3 GOEXPERIMENT=simd`, main `4b43f8c99b`. The control uses the unchanged whole-column read/converter and main's exact ranking function; the candidate uses chunk-native execution. | Scoped ObjectIO workload | Main elapsed/read | Candidate elapsed/read | |---|---:|---:| | Whole decoded-cache hit | 333.9 us | 308.9 us | | Legacy LZ4 under cache pressure | 649.0 us | 615.1 us | | Four chunks, all rows, disk cache warm | 5.923 ms | 1.234 ms | | Four chunks, selection in one chunk | 5.584 ms | 0.392 ms | | Four chunks, local store without disk cache | 6.524 ms | 2.397 ms | For the all-row pressure case, process CPU/read was **17.965 -> 1.242 ms** and Go allocation volume **61.4 MB -> 14.8 KB**. The largest returned decoded allocation was **16 MiB -> 4 MiB**; tests verify that the iterator holds at most one at a time. These are not total-process RSS measurements. The fixture uses 4,096 synthetic 768-dimensional vectors with four existing-format chunks, including LZ4 and raw payloads. Pressure cases pin an 8 MiB memory cache; the hot-cache control uses 64 MiB. All-row FileService.Read calls increase from one to six, while sparse selection reads only one payload. Call counters are logical calls, not network requests. **These are not SQL QPS or Wiki-10M results.** Both compatibility controls meet the 5% median regression gate. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…igin#28413) ## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [x] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#24097 — query execution performance improvements, particularly decompression overhead and repeated allocation. This contributes to the umbrella issue without closing it. Related investigation: matrixorigin#27854. This PR is separate from matrixorigin#28002 and does not claim Wiki-10M performance recovery. ## What this PR does / why we need it: Reuse validated decompressed object-column data across overlapping scoped Top-K reads when memory-cache admission is unavailable. Keep compressed I/O and cache updates per read, and leave memory hits and unscoped readers on their existing paths. Bound sharing by decoded backing bytes, live generations and participants. Preserve the concrete validated cache-data type, independent cancellation, bounded fallback and generation-safe final release. Protect active reads and deferred cache updates during file-service shutdown without waiting for Top-K consumers. Add fixed-cardinality sharing metrics, deterministic ownership and failure-path tests, a persisted ObjectIO Top-K consumer test, and cache-pressure/control benchmarks. ## Design and scope The decompression-only design was approved before implementation; the code is included in this same PR. [Design, ownership model, limits and validation record](https://github.com/aunjgr/matrixone/blob/1849b408dd/docs/design/scoped_shared_column_decode.md). - Opt-in: single-column scoped `LoadColumnDataByTopN` reads only. - Limits: at most 64 MiB (also capped by initial cache capacity), 64 live generations, 128 participants per generation, and a 200 ms follower wait before independent fallback. - No idle result retention, background worker, storage-format change, or cross-CN sharing. - Fused INCLUDE reads, chunked Top-K execution, allocator buffer reuse, persistent-cache resizing and quantization are outside this change. ## Evidence and validation - Normal owning packages: FileService, ObjectIO, ObjectIO/ioutil, metrics/v2 and the block-reader consumer. - Race: FileService, ObjectIO and ObjectIO/ioutil; focused lifecycle tests individually repeated 100 times after measuring their race-mode duration. - Failure coverage: cancellation of either role, timeout, ordinary/partial-result errors, panic abandonment, oversized/rejected admission, stale-generation cleanup, final physical release, and Close during conversion or deferred cache update. - Actual disk-cache fixture: eight overlapping reads execute one decompression into the same backing allocation, with no object-store GET. ObjectIO tests preserve the validated-data marker and independent query vectors, selections and thresholds. - Five 3-second microbenchmark samples against literal main FileService source: overlapping batch **180.9 → 148.0 µs** and **8 → 1 decompressions**. Memory-hit median **693.8 → 699.7 ns** (+0.9%, no extra allocation count); independent-key batch **180.3 → 186.6 µs** (+3.5%). Both controls remain within the 5% median regression limit. The descriptor is stored inline to avoid per-read allocation, and Release snapshots only owned resources. - Synthetic SQL on merged main `f8a690cb21`, before the final metadata-allocation cleanup: 32,768 × 768-dimensional vectors, eight index objects, two CNs, concurrency 100, 32 MiB cache. Mean CPU/query **147.1 → 122.2 ms**, QPS **201.1 → 242.3**, decoded backing allocation **129.2 → 104.8 MB/query**, and decompressions **7.93 → 6.45/query**. Exact rows and distances matched. - Large-cache control: both modes performed zero decompressions; QPS differed by about 1%. Short high-QPS samples have noisy tails; no tail-latency recovery claim is made. SQL comparisons toggle only sharing off/on/on/off in one locally instrumented binary against the same index contents. All temporary measurement hooks are removed from this PR. These are synthetic mechanism measurements, **not Wiki-10M acceptance results**. No dataset was downloaded or remote benchmark dispatched. - Final shared-decompression statement coverage: **94.9% (186/196 statements)**. - Full pre-push gate passed: package graph, MO lint, license headers/dependencies and golangci-lint (**0 issues**). Local tooling uses Go 1.26.4 and `-buildvcs=false` because an unrelated empty `/tmp/.git` prevents VCS stamping; no repository source or SCA rule is changed for that workaround. - Newest authoritative main `3d46ea965a` is merged. Its final JSON_QUOTE update does not alter this feature's runtime or benchmark path. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…in#28434) ## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [x] Documentation - [ ] Feature - [ ] Test and CI - [x] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#24097, following matrixorigin#28413. This contributes to query-execution performance improvements without closing the umbrella issue. ## What this PR does / why we need it: Compute vector Top-K directly over eligible chunked object columns instead of reconstructing, concatenating and reserializing the entire column. Preserve existing decoded whole-column cache hits and the legacy, synthetic-column and unsorted-selection fallbacks. Use one incremental candidate accumulator across chunks while retaining the reader-wide distance heap, original selection ordinals, duplicates, non-finite behavior and distance bounds before heap admission. Read only selected payload ranges, validate directory and payload contracts, and keep each decoded view inside its complete IOVector lease before releasing it and advancing. Reuse scoped decompression sharing at chunk granularity without adding buffer recycling, allocator pools or write-format changes. Add tiny persisted fixtures for ranking, corruption, cancellation, sharing and Close, together with cache-pressure and compatibility benchmarks. ## Design and scope [Design and validation record](https://github.com/aunjgr/matrixone/blob/perf/chunk-native-topk/docs/design/chunk_native_topk.md). - `LoadColumnDataByTopN` keeps its signature and delegates to ObjectIO's scoped `ReadColumnTopN` entry point. - Streaming is limited to existing `Lz4Chunked` extents and nil/nondecreasing selections. Unsorted inputs keep their existing tie order through the old path. - Retain at most one decoded chunk plus its compressed buffer, the bounded directory and O(K) ranking state. Existing cache/sharing budgets remain independent. - No decoded-buffer recycling, writer rollout, data rewrite, new format/protocol, fused INCLUDE expansion or additional parallelism. - More cold range-read calls are a tradeoff; this is not a claim about remote-storage latency or legacy-file performance recovery. ## Validation - ObjectIO, ObjectIO/ioutil and persisted block-reader owning suites in normal mode; production `GOAMD64=v3 GOEXPERIMENT=simd` mode also tested. - Owning-package race checks, plus 100 repetitions of the exact concurrent sharing/Close test after its measured race duration. - Selection/tie/displacement, reader-wide seeded heap, all six vector representations, NULL/non-finite/range behavior, malformed directories and payloads, errors after earlier chunks, cancellation, Close, wide offsets and skipped unselected payloads. - Differential check against main's exact ranking function: 64 deterministic cases matched rows and distance bits. - Existing `vector_ivf_topk_consumers` BVT: **58/58 statements passed twice** in normal comparison mode, with database teardown verified after each run. - New chunk-reader statement coverage: **91.7% (100/109)**. - Static analysis passed with **0 issues**: package graph, MO lint, license checks and golangci-lint. ## Performance evidence Five matched samples, Go 1.26.4, Linux amd64, `GOAMD64=v3 GOEXPERIMENT=simd`, main `4b43f8c99b`. The control uses the unchanged whole-column read/converter and main's exact ranking function; the candidate uses chunk-native execution. | Scoped ObjectIO workload | Main elapsed/read | Candidate elapsed/read | |---|---:|---:| | Whole decoded-cache hit | 333.9 us | 308.9 us | | Legacy LZ4 under cache pressure | 649.0 us | 615.1 us | | Four chunks, all rows, disk cache warm | 5.923 ms | 1.234 ms | | Four chunks, selection in one chunk | 5.584 ms | 0.392 ms | | Four chunks, local store without disk cache | 6.524 ms | 2.397 ms | For the all-row pressure case, process CPU/read was **17.965 -> 1.242 ms** and Go allocation volume **61.4 MB -> 14.8 KB**. The largest returned decoded allocation was **16 MiB -> 4 MiB**; tests verify that the iterator holds at most one at a time. These are not total-process RSS measurements. The fixture uses 4,096 synthetic 768-dimensional vectors with four existing-format chunks, including LZ4 and raw payloads. Pressure cases pin an 8 MiB memory cache; the hot-cache control uses 64 MiB. All-row FileService.Read calls increase from one to six, while sparse selection reads only one payload. Call counters are logical calls, not network requests. **These are not SQL QPS or Wiki-10M results.** Both compatibility controls meet the 5% median regression gate. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
XuPeng-SH
added a commit
that referenced
this pull request
Nov 8, 2026
) to 4.2-dev (#32361) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes #32223 Backport of #28918 and the scoped column-decode prerequisite from #28413 to `4.2-dev`. ## What this PR does / why we need it: Concurrent reads of the same immutable array column can all miss MemCache and independently read and decompress a warm DiskCache extent. For eligible scoped Top-N reads, coordinate a bounded warm-disk fill and reuse an immutable decoded result while overlapping consumers hold their read vectors. Followers recheck the existing MemCache and fall back independently on rejection, wait timeout, or failed work; caller cancellation and a close observed by a failed disk conversion stop before another tier. The 4.2 FIFO cache remains responsible for admission and eviction; restore its existing pre-allocation eviction and remove the separate reservation counter. Decode generations have their own bounded lifetime and addressable-backing budget, with unknown or oversized results bypassing sharing. No SQL, wire, catalog, or on-disk format changes are required. ## Validation - Go 1.26.4 and 4.2-built native libraries: full normal and race tests for `pkg/fileservice`, `pkg/fileservice/fifocache`, `pkg/objectio`, `pkg/objectio/ioutil`, `pkg/util/metric/v2`, and the `pkg/vm/engine/tae/blockio` consumer. - CI coverage flags (`-short -tags matrixone_test -covermode=set` and the CI list of 439 instrumented packages) against those owning/consumer packages, including the formerly failing FileService and ObjectIO tests. This is not a full repository CI run. - Twelve exact concurrency/lifecycle/CI regression tests passed adaptive race repetitions (14–100 per test, using a 30-second target and the measured per-test runtime). A persisted S3FS `LoadColumnDataByTopN` test compares shared and unshared results with real cache rejection, different queries, selections, bounds, and cleanup. - Incremental `gofmt -s`, `go vet`, MatrixOne `molint`, and repository-configured `golangci-lint` over the affected closure and complete PR patch. - On 4.2, three 1-second samples of a controlled warm-disk Top-N pair retained two decoded owners without sharing and one with sharing; median latency was 184.9 µs versus 171.0 µs, with 120 versus 134 allocations per pair. This is a small, forced-overlap mechanism test, not evidence of restored 10M-workload QPS. In an admissible eight-reader warm-fill control, disk reads fell from about 4.46 to 1 per batch and median time from 279 to 226 µs. Other FileService controls cover pressure rejection, memory hits, independent keys, and cold object-store reads. A separate unscoped baseline/current control kept allocation counts unchanged (5 per memory hit and 53 per cold read); the larger entry increased measured bytes per operation by about 32 and 65 bytes respectively. The separate CI failure in `TestIssue27966FrontendIVFInternalSQLPreservesQueryPool` occurred during initial four-CN label setup with HAKeeper timeouts, before its SQL workload; a direct causal connection to this change has not been established. The same four-CN test passed locally on this revision in normal mode and under `-race`. --------- Co-authored-by: bRong Njam <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: GreatRiver <[email protected]>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
Related to #24097 — query execution performance improvements, particularly decompression overhead and repeated allocation. This contributes to the umbrella issue without closing it.
Related investigation: #27854. This PR is separate from #28002 and does not claim Wiki-10M performance recovery.
What this PR does / why we need it:
Reuse validated decompressed object-column data across overlapping scoped Top-K reads when memory-cache admission is unavailable. Keep compressed I/O and cache updates per read, and leave memory hits and unscoped readers on their existing paths.
Bound sharing by decoded backing bytes, live generations and participants. Preserve the concrete validated cache-data type, independent cancellation, bounded fallback and generation-safe final release. Protect active reads and deferred cache updates during file-service shutdown without waiting for Top-K consumers.
Add fixed-cardinality sharing metrics, deterministic ownership and failure-path tests, a persisted ObjectIO Top-K consumer test, and cache-pressure/control benchmarks.
Design and scope
The decompression-only design was approved before implementation; the code is included in this same PR. Design, ownership model, limits and validation record.
LoadColumnDataByTopNreads only.Evidence and validation
f8a690cb21, before the final metadata-allocation cleanup: 32,768 × 768-dimensional vectors, eight index objects, two CNs, concurrency 100, 32 MiB cache. Mean CPU/query 147.1 → 122.2 ms, QPS 201.1 → 242.3, decoded backing allocation 129.2 → 104.8 MB/query, and decompressions 7.93 → 6.45/query. Exact rows and distances matched.SQL comparisons toggle only sharing off/on/on/off in one locally instrumented binary against the same index contents. All temporary measurement hooks are removed from this PR. These are synthetic mechanism measurements, not Wiki-10M acceptance results. No dataset was downloaded or remote benchmark dispatched.
-buildvcs=falsebecause an unrelated empty/tmp/.gitprevents VCS stamping; no repository source or SCA rule is changed for that workaround.3d46ea965ais merged. Its final JSON_QUOTE update does not alter this feature's runtime or benchmark path.