Skip to content

perf(objectio): compress directly into writer arena on 4.2 - #32775

Merged
XuPeng-SH merged 1 commit into
4.2-devfrom
codex/32751-direct-arena-compress-42-20261115
Nov 16, 2026
Merged

XuPeng-SH merged 1 commit into
4.2-devfrom
codex/32751-direct-arena-compress-42-20261115

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • Improvement

Which issue(s) this PR fixes:

Related to #32751; 4.2-dev counterpart of #32774.

What this PR does / why we need it:

When an arena has enough unused capacity for the LZ4 compression bound, compress independently owned writer buffers directly into its tail and commit only the actual output length. This avoids the separate compression scratch buffer and the subsequent copy on those writes. The existing scratch path remains in use when the bound does not fit or no arena is available.

The internal serialization and metadata buffers are created independently of the arena and marked with a private ownership type. WriteWithCompress, which accepts arbitrary borrowed bytes, always keeps the original scratch path even when the bytes happen not to overlap. Thus existing external callers retain their previous behavior, while the in-tree serialization and metadata paths can use direct compression. The object format, extent and arena accounting, SQL behavior, and 4.2 pool limits are unchanged.

No unsafe import, new linter exception, or linter pin change is needed on 4.2. This PR no longer depends on the unmerged linter compatibility branch in linter #58. The main implementation and its reviewed narrow exception are tracked separately in #32774 and linter #57.

Validation

On CPU-only 57, Go 1.26.4, final commit 93e4450817 rebased onto 25305b6137:

  • The complete pkg/objectio suite passed normally and under race. This includes the new direct-compression, overlapping/adjacent borrowed inputs, empty and incompressible input, no-arena and insufficient-tail fallbacks, arena reuse, multicolumn readback, and the new base's S3-cache interaction tests. For these runs the existing hardcoded test directory was temporarily redirected into the task-owned test directory and restored afterwards.
  • The independent concurrent-arena test also passed 100 race repetitions before the final rebase; the full race run passed again on the final base.
  • Official merged molint check -mod=readonly ./pkg/objectio passed; the existing selected golangci checks passed. A separate negative control verified that the official checker fails on an injected unapproved unsafe import.
  • A 1-CN LOAD/ALTER run with one 8 MiB field and 31 64 KiB fields verified all 32 complete payload hashes after each operation. The test services exited and their isolated data was removed.
  • Four alternating shared-host benchmark pairs showed similar small-input and 4-producer allocations and timings to the previous overlap-guard implementation. A further eight alternating 8 MiB pairs had a +2.38% median latency difference, with individual pairs from -12.34% to +8.82%; this noisy sample does not establish a stable regression or improvement. Both versions measured 16 B/op and 1 alloc/op in that direct-path benchmark. Earlier comparisons of the overlap-guard version against the original scratch baseline showed a benefit for the 8 MiB direct path; those earlier measurements are not a direct measurement of this final commit.

The 4.2-dev go vet -vettool SCA step has a pre-existing limitation: it can print linter diagnostics while returning success. This was reproduced with a negative control and observed in a previous green CI run. This PR does not change that branch-wide CI behavior, so the standalone official molint check above is independent evidence for the modified package; a green legacy SCA job alone is not proof that its linter findings were enforced.

Large rows whose compression bound cannot fit in the remaining arena still use the existing scratch path; this optimization alone does not resolve the original very-large-row OOM.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify

mergify Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Nov 15, 2026
@XuPeng-SH

XuPeng-SH commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · superseded

Commit: 9b3b68c7c77aefd8abd68c2ac01f0f5a1c557213

Review discussion changed before publication; a fresh contextual review is queued.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Independent QA challenge (base 6dd9f9d5588e, head 9b3b68c7c77a)

Result: no confirmed correctness, object-format, or concurrency blocker in the tested scope. I compared isolated base/head worktrees on macOS/arm64 (Apple M4, Go 1.27.1) using the repository CGo wrapper. Custom QA files were kept outside the PR production diff.

Correctness and negative control

  • All new direct-compression tests passed, including exact bound, insufficient tail, overlapping input, no arena, empty/incompressible input, independent concurrent arenas, and multi-column object readback after arena reuse.
  • Full pkg/objectio tests passed: ok ... 5.089s.
  • Full package race test passed: ok ... 5.487s.
  • Focused direct/fallback/concurrent tests passed 100 race repetitions: ok ... 2.412s.
  • An independent LZ4 oracle covered 21 cases: sizes 0/1/31/255/4096/65536/1048576 × zero/text/deterministic-varied inputs. It checked exact compressed bytes, decompression, extent metadata, input immutability, existing arena-prefix preservation, and usedOffset/totalRequested accounting. The same semantic oracle passed on both base and head.
  • Additional partial-overlap probes passed for an input starting before the unused tail, starting inside the tail, and a non-overlapping used prefix.
  • Copying the PR test to the base produced the expected negative control: head passed, while base failed optimization-specific assertions such as the arena tail replaces compression scratch. The independent semantic oracle still passed on base, distinguishing the performance change from a compressed-data semantic change.
  • Independent source review found no confirmed reachable defect in overlap detection, fallback, error-path offset commitment, or arena accounting.

Supplemental ABBA microbenchmarks

Order: base / head / head / base, 5 samples per run, 300 ms per sample; entries are medians of 10 samples. Arenas and scratch are reused, so these measure steady-state compression/copy cost rather than cold RSS or SQL throughput.

Scenario Base Head Delta
~5.5 KiB text, direct eligible 705.05 ns 699.85 ns -0.7%
~8 MiB highly compressible text, direct eligible 811.71 µs 809.67 µs -0.3%
8 MiB varied input, direct eligible 320.00 µs 163.98 µs -48.8%
~8 MiB text, bound-1 fallback 813.08 µs 812.27 µs -0.1%
8 MiB varied input, bound-1 fallback 321.42 µs 317.84 µs -1.1%

The large varied-input case benefits materially from removing the scratch-to-arena copy. Small inputs, highly compressible input, and fallback paths are effectively flat in this run; there is no observed fallback regression beyond sample noise.

Validation boundary

I did not independently rerun SQL LOAD/ALTER row hashes, process-level RSS measurements, or a multi-CN deployment. Those remain covered by the PR validation and CI rather than by this local run. At the time of this comment, Analyze(go), CodeQL, shared build, and UT coverage have passed; Ubuntu UT, SCA, and the two multi-CN BVT jobs are still pending.

@XuPeng-SH

XuPeng-SH commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: 9b3b68c7c77aefd8abd68c2ac01f0f5a1c557213

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 9b3b68c7c77aefd8abd68c2ac01f0f5a1c557213

Assessment: approve

The fast path reuses the existing arena and accounting, preserving 4.2 workspace/pool limits, encoding and required fallbacks. Avoiding compression scratch and copying justifies the small added checks.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Full pkg/objectio normal and race suites passed with Go 1.26.6: 76 top-level tests each, including all five new cases and existing workspace/budget tests.

  • The independent-arena test passed 100 focused race repetitions; both selected sinker layout/workspace consumers passed under race.

  • go vet, gofmt, complete-delta whitespace, preflight and native prerequisite verification passed.

  • validation-audit.json reconciles ten local validation receipts with retained logs. All five discussion entries are accounted for; exact-head macOS QA corroborates the assessment. Source remains unchanged.

Limitations:

  • Author/QA SQL, RSS and benchmark figures were not independently reproduced or checked against raw logs. This assessment does not close #32751 or establish production OOM resolution.

  • Hosted validation was incomplete in the structured snapshot; QA reported later progress without a refreshed structured status.

@XuPeng-SH

XuPeng-SH commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: d76e4f8dbdd687c64f98c32bd01a1e649af4875b

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: d76e4f8dbdd687c64f98c32bd01a1e649af4875b

Assessment: approve

The fast path reuses 4.2's existing arena, codec and accounting while preserving workspace/pool limits, encoding and required fallbacks. Avoiding compression scratch and copying justifies the small checks. The isolated overlap helper and legacy linter pin preserve the writer's unsafe restriction. No blocking findings remain.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Read the complete five-file delta and 4.2 writer, workspace, pool/reaper, Sync and reader consumers. All seven discussion keys are covered in discussion-assessment.json; identical linked #32751 context was compared and reused within the batch.

  • Current-head pkg/objectio normal and race suites passed 82 top-level roots each with Go 1.26.6, isolated test-exec runtimes and unchanged source/test paths.

  • The independent-arena test passed 100 focused race repetitions (T=0.01s, B=30s, N=100). Both selected Sinker persisted-layout/workspace consumers passed under race.

  • Compared the complete old/new legacy molint modules: only the helper approval and its tests differ. Pinned policy tests, installed go vet -vettool, standard go vet, gofmt and complete-delta whitespace checks passed.

  • Preflight and native provenance checks passed: 170 current native inputs and 43 retained outputs matched. validation-audit.json reconciles commands, frozen source, exits and retained logs.

Limitations:

  • Author/QA SQL, RSS/profile and benchmark reports were assessed without independently reproducing their raw runs. No universal latency, production OOM or umbrella #32751 completion claim is established.

  • Hosted shared-build, UT, SCA, coverage, E2E and Go-analysis validation remained incomplete in the frozen snapshot; skipped jobs were not counted as passes.

@XuPeng-SH
XuPeng-SH marked this pull request as draft November 15, 2026 23:16
@XuPeng-SH
XuPeng-SH marked this pull request as ready for review November 15, 2026 23:45
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH

XuPeng-SH commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: 93e4450817d517622d95edaed91914499c68758e

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 93e4450817d517622d95edaed91914499c68758e

Assessment: approve

Approve the scoped 4.2-dev compression optimization. Independently owned serialization buffers establish non-aliasing while reusing the existing codec, arena allocation/accounting and scratch fallback. Borrowed inputs retain baseline behavior, and workspace/pool budgets remain intact. Current boundary, byte/extent, readback, consumer and race evidence closes the affected contracts; prior reviews and QA were reconciled with the new ownership boundary. No actionable findings remain.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Full objectio package: 84 root tests/seed runs passed normally and under race detection, including all seven added roots; no skips. Receipts and retained JSON logs: validation-audit.json, objectio-normal.jsonl, objectio-race.jsonl.

  • Three real sinker/workspace consumers passed under race detection. The independent-arena test passed 100 repetitions, selected from its measured race duration. See ioutil-consumers-race.jsonl, arena-stress-race.jsonl and race-stress-plan.json.

  • Pinned golangci-lint v2.6.2 passed configured analysis of objectio and objectio/ioutil with the repository's existing exclusions; changed Go files are gofmt clean and git diff --check passed. See golangci-selected., source-audit..

  • Preflight passed; reused native prerequisites matched all 170 current inputs, 71 artifact hashes and compiler identity. All claimed checks were reconciled to frozen-head command/source/exit receipts and retained logs; all ten discussion keys are covered exactly once.

Limitations:

  • No new whole-SQL, RSS, GPU or performance benchmark campaign was run. Historical author/QA measurements are reported context, not current frozen-head execution proof; the tracker remains broader than this component optimization.

  • The unchanged branch pin molint 222a0b8adf07 supports only its legacy vettool interface. Its prescribed invocation exited 0 with empty JSON; that exit is not treated as independent diagnostic enforcement. Configured golangci analysis and source policy review cover the changed paths. The attempted standalone invocation was unsupported, not a product-test failure.

  • Initial dependency/tool setup timeouts were recovered using the same task caches. Evidence for external linter discussions #57/#58 was not supplied correctly; this delta changes neither unsafe usage nor the linter pin.

@XuPeng-SH
XuPeng-SH merged commit 04610fe into 4.2-dev Nov 16, 2026
@XuPeng-SH
XuPeng-SH deleted the codex/32751-direct-arena-compress-42-20261115 branch November 16, 2026 02:03

This branch was previously deployed

1 inactive deployment
ci — 93e44508 Deployed Nov 16, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants