Skip to content

fix(pSpool): preserve batch reuse without planning slices on 4.2-dev - #32758

Merged
XuPeng-SH merged 3 commits into
4.2-devfrom
codex/32751-cache-lifetime-42
Nov 15, 2026
Merged

XuPeng-SH merged 3 commits into
4.2-devfrom
codex/32751-cache-lifetime-42

Conversation

@XuPeng-SH

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

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • 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:

Preserve batch-wide large-buffer reuse while removing per-batch planning slices and correcting undersized-fallback order. Seed [1 KiB, empty], then [2 KiB, 4 KiB] previously peaked at 7,216 B because the old block was released late; source-order fallback now peaks at 6,192 B. The [1 MiB, 128 MiB] real-Vector diagnostic retains about 129 MiB target native backing/peak. Main counterpart: #32754.

Exact hits and current needs that dominate future needs reuse backing directly. Other needs are visited largest-first through source/destination fields and a constant-size cursor, followed by source-order undersized fallback. Best-fit loops reject insufficient or already-worse capacities before checking allocation provenance. Both predicates are read-only; selection/tie order and AttachTo's validation are preserved. There are no request/copy-index slices, sorting workspace, new pools or retained planning references. Worst-case work remains O(N² + N·B).

Restore the mixed-shape native-retention assertion across eight shapes. Preserve complete values/NULL/constants/nil/aliases and physical-budget failure after a copied prefix -> slot return -> retry. Smallest-sufficient backing and prefix/current/future alias controls pass; both pools reach zero. A separate brute-force diagnostic passes 1,728 orchestration combinations against maximum covered need and minimum sufficient capacity.

The final predicate-order change addresses the prior serial wide-changing CPU regression. Machine 57, Go 1.26.4, six samples per revision for 128 alternating-size columns: base median 98,438.5 ns/op, prior revision 102,937, final 93,092 (-5.4% vs base). Go cost remains 45,312 -> 29,696 B/op, 389 -> 384 allocs/op (~34.5% fewer Go allocation bytes). Four-producer results remain sensitive to topology and concurrent host work; a complete run overlapped unrelated Rust compilation. Do not treat those runs as final concurrent acceptance or infer that wide queries have low internal DOP.

After the final code change, full pSpool/connector/dispatch normal and race UTs, scoped vet, incremental lint (0 issues), native 129 MiB diagnostic and independent matching oracle all pass. Earlier public-API spool QA passed 10 race repetitions; the public ownership path is unchanged. The actual 4.2-dev base fails the 7,216 <= 6,192 growth guard; the candidate passes without relinquishing the large-buffer saving.

Base: ad39691b6b. Keep draft pending stable concurrent-performance review and final-head CI. These component tests do not establish CN RSS, query p99, idle recovery or an OOM fix.

@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.

@XuPeng-SH

XuPeng-SH commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: e60469a865e4676a8b9726e1831bb77480c65638

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: e60469a865e4676a8b9726e1831bb77480c65638

Assessment: approve

Restoring the existing per-vector owner removes planner scratch and allocation-lifetime overlap. Exact-fit exits preserve selection; functional, provenance and failure coverage remains. The explicitly deferred cross-column optimization does not block this scoped correction.

Model: gpt-6.1-sol / max

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

Validation:

  • Reviewed the complete six-file delta, ownership/consumer paths, all discussion entries and linked #32751 scope.

  • Static checks passed: frozen source/patch, formatting, pre-P2 equivalence except two exact-hit exits, retained test coverage, and 187245 independent selection-model cases.

  • Isolation preflight passed. Canonical pSpool/connector/dispatch tests stopped before compilation on missing libmo.so; logs and receipts retained.

  • Assessed author-reported native normal/race checks, negative peak control, benchmark smoke and paired throughput controls.

Limitations:

  • Native execution and performance results were not independently reproduced; raw author logs/native artifacts were unavailable and relevant frozen CI is nonterminal.

  • Source-order reuse restores the disclosed cross-column amplification; no end-to-end OOM or CN RSS improvement is established.

@matrix-meow matrix-meow added size/L Denotes a PR that changes [500,999] lines and removed size/M Denotes a PR that changes [100,499] lines labels Nov 15, 2026
@XuPeng-SH XuPeng-SH changed the title fix(pSpool): restore source-order cache reuse on 4.2-dev fix(pSpool): preserve batch reuse without planning slices on 4.2-dev Nov 15, 2026
@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 15, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: 29f82481b45754ea2c5f1d2a1c015231a08bf96f

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: 29f82481b45754ea2c5f1d2a1c015231a08bf96f

Assessment: request_changes

The replacement keeps the existing buffer owner and sufficient whole-batch reuse, removes request/copy-index scratch and assigns undersized backing in source order. Source reasoning and the focused model support the growth-peak correction without relinquishing the baseline's large-buffer saving; aliases, allocation provenance and failure cleanup remain intact. The added fast paths/cursor are justified by that component goal, but the explicitly retained concurrent-performance acceptance gate is still open. No production regression is asserted.

Model: gpt-6.1-sol / max

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

  • P2 pkg/container/pSpool/copy.go:223: Accepting the replacement reservation/copy orchestration for concurrent pipeline producers before the stable concurrent-performance gate retained in this PR and linked issue #32751 is closed.
    Impact: The accepted cost of the new cursor scans and suffix preparation under concurrent wide/changing/bulk batches remains undetermined. The reported serial result is favorable, but the only described full concurrent round overlapped unrelated compilation and is explicitly excluded. This is a material unmet component-validation requirement, not evidence of a measured concurrent slowdown.
    Evidence: The frozen PR body reports the final serial 128-column control at 98,438.5 -> 93,092 ns/op (-5.4%), 45,312 -> 29,696 B/op and 389 -> 384 allocs/op, while stating that four-producer results are topology/host-work sensitive and must not be treated as final acceptance. Both that body and linked #32751 P2/P2a keep stable concurrent-performance review pending; the tracker additionally retains cross-machine fixed-path review. Use the maintained independent-producer fixture to compare this final revision with ad39691 under isolated, matched conditions for the affected wide/changing and bulk paths plus a fixed-path control, and record terminal results, allocations and the acceptance conclusion. Resolve the retained cross-machine control where applicable. No whole-CN RSS/OOM or query-p99 campaign is required for this scoped correction.

Validation:

  • Read the complete six-file frozen delta, all six discussion entries and the 4.2-dev baseline. Reused the fully read linked #32751 body only after proving its byte identity across batch evidence. Traced SendBatch/CacheBatch, actual branch failure defer, alias cleanup, allocation-site compatibility and unchanged cache eviction ownership.

  • PASS: finite source-transcribed matching model versus an independent exhaustive sufficient-assignment oracle, 28,288 cases. Verified the common owned-matching helpers against the first batch member (omitting only its main-only borrowed skip guards), clean exact HEAD, source hashes and supplied patch equivalence to Git's frozen delta (terminal newline ignored). An abstract backing-liveness trace also distinguishes 7,216/6,192-byte baseline/candidate peaks; this is source-level reasoning, not native execution. Receipt checks/1794727406146510391-2.json; reservation_model.py, reservation-model.log and reservation-model-result.json retained.

  • PASS: gofmt across all six changed Go files and stored PR template headings/LF checks. Receipt checks/1794727434691280122-2.json; static-audit.log retained.

  • Assessed attributed final-head author reports of full pSpool/connector/dispatch normal and race tests, scoped vet, incremental lint, native 129MiB diagnostic and 1,728-case oracle, plus unchanged-boundary public-API race QA. The serial throughput and allocation improvement is supporting evidence; the excluded concurrent round is not acceptance.

Limitations:

  • No local native Go tests or throughput benchmarks were run. local_validation is empty and raw author native execution/provenance logs were not supplied; reported passes and measurements are attributed. The finite model does not execute real Vector allocation, payload copying, failure injection, leases or concurrency.

  • The frozen hosted snapshot has five checks in progress, five cancelled and CI Required FAILURE, without a causal product-failure log. Pending, cancelled, skipped and aggregate results are not counted as product passes or confirmed product defects.

  • Scope is this component correction on 4.2-dev. Its baseline already has sufficient whole-batch reuse and cache-limit support; the review does not claim a new whole-CN memory/OOM fix or demand completion of the tracker's separate P3-P7 work.

@XuPeng-SH
XuPeng-SH merged commit 296402f into 4.2-dev Nov 15, 2026
@XuPeng-SH
XuPeng-SH deleted the codex/32751-cache-lifetime-42 branch November 15, 2026 09:40
XuPeng-SH added a commit that referenced this pull request Nov 15, 2026
## What type of PR is this?

- [ ] API-change
- [x] 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:

Reserve cached backing across the uncopied batch suffix without
allocating request or copy-index slices. After caching `[empty, 128
MiB]`, copying `[1 MiB, 128 MiB]` previously let the small column
consume the only large block. The revised real-Vector diagnostic uses
about **129 MiB target native backing/peak instead of 256 MiB**,
preserving every payload byte. This is a component result, not a CN
RSS/OOM claim. 4.2-dev counterpart: #32758.

Exact compatible hits and current needs that dominate future needs can
reuse backing directly. Other needs are visited largest-first through a
constant-size cursor, followed by source-order undersized fallback.
Best-fit searches first reject insufficient or already-worse capacities
before checking allocation provenance; the chosen block, tie order and
attachment checks are identical. Logical needs replace historical spare
backing size. Payloads and borrowed snapshots remain in source order.
There is no retained planning state, new pool or configuration.
Worst-case matching work remains O(N² + N·B).

The mixed-shape native-retention assertion is restored across eight
shapes. Values, NULL/constants/nil, aliases and allocation failure after
an already copied prefix -> slot return -> retry remain covered. Add
smallest-sufficient and alias-boundary controls; both pools must reach
zero. The borrowed snapshot peak test includes an alias and protects
main base's already-correct behavior. A separate full-orchestration
oracle passes 1,728 combinations; the 128 MiB resident-page probe stays
outside CI.

Validation on machine 57, CPU-only, Go 1.27.1: full
pSpool/connector/dispatch normal and race UTs; scoped vet; incremental
golangci-lint (0 issues); real-Vector memory diagnostic and independent
matching oracle all pass after the final predicate change. Earlier
public-API round-trip/slot-reuse/snapshot/terminal QA passed 10 race
repetitions; that public API and its ownership path are unchanged.

Local fixed8192/four-producer recheck on cores 0-3 (one L3), six
1-second samples per revision: base median 303.15 ns/op, prior revision
307.20, final 305.50 (+0.78% vs base), unchanged B/op and allocs/op.
Cross-L3 results vary substantially: an initial +10% result did not
persist in the repeat. A full concurrent benchmark round overlapped
unrelated Rust compilation and is excluded from acceptance. The
maintained benchmark covers 10 fixed/exact/spare/changing/wide/bulk
shapes, with independent source/cache/MPool ownership per producer.

Rebased onto main `d1893e5ae7`. Keep draft pending stable
concurrent/cross-hardware performance review and CI at the final head.
Local measurements do not establish query p99, whole-CN memory recovery
or universal performance acceptance.

This branch was previously deployed

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

Labels

kind/bug Something isn't working kind/enhancement size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants