Repository navigation
checkunsafe: approve isolated object compression overlap guard - #57
Merged
XuPeng-SH merged 1 commit intoNov 15, 2026
Merged
Conversation
This was referenced Nov 15, 2026
XuPeng-SH
deleted the
codex/objectio-compression-overlap-unsafe-20261116
branch
November 15, 2026 23:33
XuPeng-SH
added a commit
to matrixorigin/matrixone
that referenced
this pull request
Nov 16, 2026
## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #32751 ## What this PR does / why we need it: The object writer currently compresses into a separate scratch buffer and then copies the compressed bytes into the writer arena. When the unused arena tail already fits the LZ4 compression bound, that creates an avoidable live allocation and copy. Compress directly into the unused tail when it is large enough and does not overlap the input. Commit only the actual compressed length to the arena after success. Inputs overlapping the tail, insufficient space, and writers without an arena keep the existing scratch path. The LZ4 format, extent metadata, ownership of completed output, and arena accounting remain unchanged. Validation on a CPU-only 57 host: - Exact compressed bytes, offsets, NULLs, multiple sequential writes, alias and insufficient-capacity fallback, and an in-memory object write/read after arena reuse were checked. The full objectio package passed normally and under race; the independent concurrent-arena test passed 100 race repetitions. Incremental lint and formatting passed. - In two isolated 1-CN LOAD/ALTER cases (one 8 MiB field and 31 64 KiB fields, large field first or last), all row hashes and strict/non-strict diagnostics matched. The load-idle native profile dropped the 16 MiB compression scratch while retaining the 32 MiB arena. Sampled LOAD RSS deltas changed 115.13→105.11 MiB and 106.39→95.11 MiB; one run per order with 5 ms sampling is not an exact peak or a production-scale estimate. - Combined with merged #32771, an additional 1-CN case preserved all hashes and diagnostics. Its sampled LOAD/ALTER RSS deltas were 96.68/34.46 MiB versus 115.13/50.46 MiB in the separate base run; profile attribution confirms both allocation reductions, but individual runs are not directly additive. - Three alternating microbenchmark rounds showed little change for 64 B–4 KiB serial inputs and about 52% lower time for 8 MiB varied input in the direct path. A four-producer 4 KiB case was 1.3% slower. The initial 8 MiB fallback samples were 4–6% slower; eight additional alternating pairs had a +0.39% median with several-percent variation. These shared-host samples do not prove a universal no-regression result. Rows whose compression bound exceeds the unused arena capacity retain the existing path; this alone does not resolve the original very-large-row OOM. ## Overlap guard and SCA follow-up - `unsafe` is confined to `compression_overlap.go`, which compares addresses without dereferencing or reconstructing pointers. The caller must keep both buffers and their owners valid and must not release the arena concurrently. `writer.go` remains subject to the unsafe-import check. Empty, same-start, containment, both partial-overlap directions, adjacent and separate slices are tested; real compression tests verify that overlapping input falls back and adjacent input uses the direct path. - The pinned molint is the official master commit `147a3f213653` merged in [linter PR 57](matrixorigin/linter#57); it no longer depends on the unmerged compatibility branch. Compared with the previous MatrixOne main pin, this version also includes three function-scoped `recover` approvals already merged in [linter PR 56](matrixorigin/linter#56). - The complete `pkg/objectio` suite passed normally and under race on the earlier PR head. After merging the latest main including #32782, compression and S3 writer/cache interaction tests passed under race, and the official merged molint plus golangci passed `make static-check-selected STATIC_CHECK_PACKAGES=./pkg/objectio` on commit `11e75981aa3ce38812484cb533c093be89bf9260`. Full CI is running on that head. The linter itself passed `go test ./...` before merge. - Comparing the guard extraction against the earlier PR head on the shared 57 host, the first three-pair 64-byte sample had a +3.35% median; six additional alternating pairs had a -0.23% paired median. The 4 KiB follow-up paired median was +0.09%. These short samples are noisy and do not establish a universal performance result.
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.
MatrixOne's object writer can compress directly into its owned arena only when the input and output byte ranges do not overlap. Approve
unsafefor the dedicatedpkg/objectio/compression_overlap.gorange check, rather than for the writer as a whole.The helper compares addresses without dereferencing or reconstructing pointers. Its callers keep the slices and their owners alive, and the associated MatrixOne change tests overlapping, adjacent, empty and separate buffers, including compression fallback. The approval is file-scoped:
writer.goremains rejected, and future unsafe changes to the helper still require review.Related MatrixOne changes: matrixorigin/matrixone#32774 and matrixorigin/matrixone#32775.
Validation:
go test ./...in this repository.make static-check-selected STATIC_CHECK_PACKAGES=./pkg/objectiowith this linter.