Repository navigation
perf: avoid temporary CSV field assembly buffers - #32766
Conversation
Append fragments into the caller-owned accumulator and preserve record/error contracts. Related to #32751.
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? |
|
This pull request is merged. |
|
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: 919bdaa326e04c5b336a10b89bfaa0691b7c299d
Assessment: approve
Direct appends reuse the existing accumulator and remove temporary field assembly without adding state or another ownership path. Framing, record bounds, errors and borrowed-field lifetime remain consistent. The disclosed retained-capacity increase is a reasonable tradeoff for this scoped optimization.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Reviewed the complete two-file delta, all three scanner callers, external CSV/JSONLINE, boundary and export consumers, existing/new test oracles, all three discussion entries and linked issue #32751.
-
Source audit passed: frozen head/base, complete patch identity, clean source, whitespace/gofmt and exact discussion coverage. Evidence: source-audit.log and checks/1794744822273591881-2.json.
-
Isolation preflight passed: preflight.log and checks/1794744514165025271-2.json.
-
Considered the author's scoped normal/race, consumer, differential, benchmark and LOAD/ALTER reports. Frozen hosted shared build succeeded; no local product-test pass is claimed.
Limitations:
-
Go 1.27.1 download timed out before compilation; local tests and benchmarks did not run. Retained diagnostic: csvparser-dependencies.log, checks/1794744770556945836-2.json.
-
Author validation raw logs were not supplied; hosted UT/SCA/coverage/BVT remained pending. Lower retained capacity, idle RSS or whole-CN OOM resolution is not established.
|
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: 5e0432142aedb5c35cd3fac5631c720769c14a20
Assessment: approve
Direct fragment appends reuse the existing row/lookahead buffers without new state or ownership paths. Framing, bounds, errors and borrowed-field lifetime remain intact. The benchmark follow-up keeps each worker’s row header local; increased retained capacity is a reasonable disclosed tradeoff for lower transient allocation.
Model: gpt-6.1-sol / max
Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0
Validation:
-
Reviewed the complete two-file delta, all three scanner callers, CSV/JSONLINE, boundary and export consumers, five discussion entries and linked issue #32751.
-
Verified production and dependent code match prior review 5910649425; independently assessed the benchmark-only follow-up.
-
Current frozen-source, patch, whitespace/gofmt, discussion and evidence audit passed: source-audit.log; checks/1794746705579674542-2.json.
-
Assessed author-reported normal/race, consumer, 4,176 differential comparisons, alternating benchmarks and full-payload LOAD/ALTER checks.
Limitations:
-
Local product tests and benchmarks were not run: installed Go 1.26.6 is below the required 1.27.1. The prior toolchain-download timeout is retained as environment evidence.
-
Author validation raw logs were unavailable; five hosted checks remain pending and skipped checks are not passes.
-
Component allocation savings do not establish lower idle RSS or whole-CN OOM resolution; geometric row growth retains more capacity.
## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #32751. Port of main #32766. ## What this PR does / why we need it: CSV fragments spanning read blocks were assembled into a temporary growing buffer and then copied into the row buffer, repeating allocation even with a reusable row buffer. Append fragments directly into the caller-owned row/lookahead accumulator, retaining the single-block path. Adapt the change to 4.2's raw record bounds and memory reservation callbacks. Growth grants still precede appends, and rejected lookahead preserves the prior empty-fragment error result. Keep the existing conservative reservation envelope. Six alternating Linux/amd64 CPU benchmark samples with Go 1.26.4: - Reused plain 1 MiB / 8 MiB fields: 3,399,680 / 43,220,992 B/op -> 0; time improves about 44% / 55%. Four concurrent 1 MiB readers improve about 58%. - Tradeoff: serial small/wide CSV framing is about 3.6% / 3.5% slower (roughly 1 ns/field). Cold row capacity after an 8 MiB field is about 9.07 MiB versus 8 MiB (1 MiB: 1.20 versus 1 MiB). This targets large-value ingestion and does not make every workload better. - Parallel fixtures keep mutable row headers local to each goroutine. Corrected small-field concurrent controls do not establish a consistent regression; initial shared-header samples are superseded. Validation: full csvparser normal/race/vet, focused external admission/reset/typed-boundary normal/race controls, 4,176 baseline/head input/config/block comparisons, and final incremental lint (0 issues). CN RSS evidence is from sibling main #32766; this port has branch-specific component and consumer validation. The pre-existing sealed-CR panic found in baseline controls is addressed independently by #32768. Full hosted CI is pending. Maintained benchmarks cover cold/reused, small/wide/quoted/large inputs and independent concurrent readers.
What type of PR is this?
Which issue(s) this PR fixes:
Related to #32751
What this PR does / why we need it:
CSV fields spanning input blocks were assembled into a temporary growing buffer, then copied into the row buffer. That temporary assembly repeated for every large field even when the parser already had sufficient row capacity. Append fragments directly to the caller-owned row/lookahead buffer, preserving the single-block fast path, framing, record bounds, EOF/read errors, and existing result lifetime.
Six alternating CPU-only benchmark samples on Linux/amd64 (Go 1.27.1):
Tradeoff: geometric row growth retains about 9.07 MiB after an 8 MiB field versus 8 MiB previously (1 MiB: 1.20 versus 1 MiB); 64 KiB controls are unchanged. This reduces temporary copies and allocation churn, and does not guarantee lower idle RSS.
Validation: full csvparser normal/race UT with vet, focused external CSV/JSONLINE consumer normal/race UT, 4,176 baseline/head input/config/block comparisons, and incremental golangci-lint (0 issues). Two real 32-row LOAD/ALTER probes (about 10 MiB payload each) preserve every full SHA256; observed LOAD RSS peaks fall about 12-13 MiB. These short 25ms-sampled probes are not production OOM or exact-peak proof. Test services/data were cleaned.
Reproduce coverage with -bench 'BenchmarkCSVRecordAccumulator' -benchmem; maintained benchmarks include cold/reused, small/wide/quoted/large fields and independent parallel readers with goroutine-local mutable row state. Full hosted CI is pending.