Repository navigation
fix(fileservice): coalesce same-key warm disk-cache column fills (#28918) to 4.2-dev - #32361
Conversation
- [ ] API-change - [ ] BUG - [x] Improvement - [x] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring 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. 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. 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. - 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>
) - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring Fixes #28898: the reproduced main-branch same-key disk-read/decode amplification mechanism. After concurrent MemCache misses, readers of the same immutable column can each read its DiskCache extent before any reader publishes decoded data. Existing scoped decode sharing starts after disk I/O and has a bounded admission quota. When that quota is exhausted, duplicate decoded allocations can evict useful cache entries before MemCache insertion detects the duplicate key. This causes avoidable read/decode amplification even when the working set fits MemCache. It is distinct from the existing cold-object S3 IOMerger path. - Coordinate an already `DecodeSharing`-marked immutable column at the `S3FS.Read` boundary, before disk I/O. Keep the existing one-selected-column eligibility and policy checks. - Enter only when DiskCache's existing index reports the full file present, or the exact range for a single-entry request. The index is a hint, not a substitute for the actual read. - Recheck MemCache before I/O. Successful disk-fill leaders notify followers only after deferred MemCache publication; followers then read through the normal cache API. - Do not start a new fill when pending memory reservations or an active memory-pressure target make publication unsuitable. This read-only hint does not reserve or evict anything, and existing same-key fills can still accept followers. - Leave coordination before remote-cache/S3 work when the disk read is incomplete. Cold/unindexed paths do not acquire a fill ticket. - Reuse the existing FileService decoded-read registry and close/read lifetime. The new records hold notification metadata only, not decoded buffers. - Limit live fill generations to 64 and participants per generation to 128. Detached generations remain charged until their final participant releases them. - At most one added fill wait per Read, bounded by one second and interruptible by cancellation or service close. Timeout/admission bypass resumes the existing read path without rejoining the fill. - Completion is a notification, not a shared error result: a failed or canceled leader does not turn a healthy follower into a failed read. - No new goroutines, global disk throttle, cache-budget/eviction changes, SQL/planner changes, routing changes, configuration, production hooks, or persistent-format changes. The committed UTs cover same-key disk-fill reuse with available and saturated decode-sharing admission, publication-before-notification, key isolation, participant/generation limits, cancellation, timeout, close, stale-generation release, memory admission, and cold-path bypass. They also retain the existing independent fallback coverage. Validation on the final file contents, based on upstream main `2ea4ec2e6ef4b20321a235ef416228506813e39b`: | Validation | Result | | --- | --- | | Full FileService package, normal | PASS, 15.592s | | Full FileService package, race | PASS, 24.557s | | Focused disk-fill/shared-decode tests, race x30 | PASS, 13.278s | | Linux FileService integration, four CPUs, x5 | PASS | | Same Linux integration, race | PASS | | `go vet ./pkg/fileservice`, formatting, diff checks | PASS | The separate Linux integration uses real FileService, DiskCache, MemCache, native allocation and LZ4 with the local disk-backed object-storage endpoint. Its baseline is `bb358ea76aeb44a6eed5079616e7e75ba35e75b9`; the candidate adds only the two production files. FileService/ObjectIO production code and dependency versions were checked for equivalence between that baseline and the main base above. The external diagnostic harness is not added to this PR. For eight overlapping requests for one missing immutable column, with seven other columns warm and decode sharing saturated: | Counter | Baseline | Candidate | | --- | ---: | ---: | | Disk reads | 8 | 1 | | Conversions | 8 | 1 | | Logical disk bytes | 295,224 | 36,903 | | Retained MemCache data after the wave | 1 MiB | 8 MiB | Payload equality and reservation/registry cleanup are checked. The cold control remains one source GET, zero disk hits and one conversion. Different-key, memory-hit, single-reader and non-admitting controls are also exercised. Adjacent four-core benchmark samples on the final candidate did not reproduce a sustained regression in different-key or memory-ineligible overlapping reads. Samples contain host noise and are not a universal no-regression or speedup claim; the metadata coordination has a small allocation cost. Reproducible owning-package checks, with the repository-supported Go/CGo environment: ```sh GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/fileservice GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/fileservice GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=30 -timeout=600s \ -run '^(TestSharedDecodeFill.*|TestS3FSSharedDecodeDiskFill.*|TestS3FSSharedDecodeDiskHits)$' \ ./pkg/fileservice ``` This fixes the reproduced mechanism with bounded coordination; it does not guarantee that every same-key miss will coalesce under timeout, cache eviction or admission pressure. Full IVF-10M SQL latency recovery and the fraction of nightly multi-TB traffic attributable to this mechanism have not been validated. No external COS test, cluster rollout or 4.2 backport is claimed. Self-review covered publication ordering, ownership, all ticket terminal paths, cancellation/close, stale generations and resource bounds. No unresolved blocker was found in this scope. Co-authored-by: XuPeng-SH <[email protected]>
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: e454008f0edf66c574ce4b9d357a610865be4128
Assessment: approve
The separate bounded fill and decode generations match publication and consumer lifetimes, and reuse FIFO admission and ObjectIO validation. No actionable defects found.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Reviewed all 17 changed paths, their owners/consumers, the linked issue and both discussion entries.
-
All 57 tests declared in changed files passed in normal and race modes. Thirteen exact race tests passed 1,155 repetitions; vet, formatting and native provenance/loader checks passed.
-
Five packages passed full normal/race runs. FileService's sole MinIO authentication failure reproduced at the frozen base; the current MinIO test passed in both modes with fixture credentials supplied.
-
Warm-fill benchmarking reduced about 7.81 disk reads/conversions to one per eight-reader batch. All 29 checks are reconciled in validation-evidence.json.
Limitations:
-
Six existing optional/integration/OOM cases were skipped. Frozen core CI was pending/cancelled; coverage-mode and four-CN author reports were not independently rerun.
-
The short mechanism benchmark does not establish production latency or restoration of incident-scale QPS.
What type of PR is this?
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
pkg/fileservice,pkg/fileservice/fifocache,pkg/objectio,pkg/objectio/ioutil,pkg/util/metric/v2, and thepkg/vm/engine/tae/blockioconsumer.-short -tags matrixone_test -covermode=setand 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.LoadColumnDataByTopNtest compares shared and unshared results with real cache rejection, different queries, selections, bounds, and cleanup.gofmt -s,go vet, MatrixOnemolint, and repository-configuredgolangci-lintover the affected closure and complete PR patch.The separate CI failure in
TestIssue27966FrontendIVFInternalSQLPreservesQueryPooloccurred 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.