Stream records without buffering the rest of the catalog
Switching to a streaming file reader did not reduce memory because validation still accumulates every parsed row before writing starts.
- Focused work estimate
- 4h + prerequisites
- Priority in the scenario
- High
- Engineering practice
- Streaming · Backpressure
Estimated field mix
- Performance engineering50%
- Data engineering50%
Field percentages are editorial estimates of the ticket's engineering focus. They total 100%; they are not measured time, proficiency scores, or ownership evidence.
Review it, then add it to your workspace.
The board opens an editable draft; nothing is saved until you confirm it. Sign-in and workspace permissions apply, and Demo boards remain ephemeral.
Project context
A fictional wholesaler imports supplier rows into a staging catalog. The current prototype reads the entire file into memory and restarts from zero after a failure. Build the prototype and generated CSV fixture locally before measuring improvements.
Setup prerequisites
- Generate a deterministic 250,000-row synthetic CSV with quoted newlines, invalid records and a stated maximum record size.
- Create a disposable staging database and an import process constrained to 256 MiB; record runtime and available CPU.
Preceding work
Complete these dependencies, or supply their agreed outputs before taking this ticket.
Acceptance criteria
- Connect reading, parsing, validation and writing through bounded buffers with downstream backpressure.
- Reject an oversized record explicitly without allowing unbounded parser accumulation.
- Preserve normalized accepted-record digest and rejection reasons from the baseline fixture.
Implementation constraints
- Express buffer bounds in records and bytes where record sizes vary; a stream API alone does not establish bounded memory.
Verification to include
- Pause the writer and assert parser progress stops within the declared buffering bound.
- Split quoted multibyte records across small input chunks and compare complete results with the reference fixture.
Deliverables
- Streaming pipeline, buffer invariants and peak-memory comparison
Rollout and recovery
Keep the whole-file implementation only as a small-fixture reference; stop and retain the source file if the streaming result digest differs.
Value of the work
For the engineer: Practice streaming, backpressure, allocation analysis and resumable work while retaining exact import semantics.
For the team: Develop a repeatable import performance and recovery exercise that exposes memory, throughput and data-quality tradeoffs.
Evidence boundaries
Outcome Evidence: Tests, patches, and runbooks are requested deliverables. They become Outcome Evidence only through a qualified Mission and immutable Evidence IDs.
Ownership Evidence: Independent adaptation must be observed under a declared verification policy and cite immutable Evidence IDs. Completing a planning ticket establishes no Ownership Evidence.