miller/pkg/input
John Kerl 5b29ad1596 EXPERIMENT (negative result): zero-copy CSV reader
Prototype of a zero-copy CSV record reader (ZeroCopyCSVReader): reads input
in large persistent blocks and returns field strings as unsafe.String views
directly into the block, eliminating the stdlib-derived parser's per-record
string() copy and recordBuffer accumulation. Unquoted records are fully
zero-copy; quoted records delegate to the go-csv parser for correctness.

Correctness: full regression suite passes, including a deterministic stress
run with a 3-byte forced block size (maximal boundary splitting). Required
fixing comment trailing-newline handling, comment-before-quote ordering, and
absolute error-line-number rewriting for delegated quoted records.

Performance: NEGATIVE RESULT -- do not merge.
  - Wall-clock neutral: CSV cat is I/O-bound (syscall ~56%) after the
    allocation-batching work, so removing the per-record copy saves CPU that
    already overlapped with I/O on idle cores (confirmed under GOGC variations
    and across cat/stats1/cut).
  - Peak RSS 2-2.6x WORSE (162MB -> 357-423MB) at every block size: zero-copy
    pins whole input blocks while any field references them, and the pipeline
    buffers up to 500 batches, so many blocks stay live at once. The stdlib
    parser's per-record strings keep memory proportional to live data.

Committed for the record; tracked in a GitHub issue. Not for merge.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 15:25:35 -04:00
..
constants.go Separate out ILineReader abstraction (#1504) 2024-02-24 22:07:56 -05:00
csv_zerocopy_reader.go EXPERIMENT (negative result): zero-copy CSV reader 2026-06-19 15:25:35 -04:00
doc.go Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
fixed_width_splitter.go Some fixes for staticcheck (#2006) 2026-03-03 09:27:03 -05:00
fixed_width_splitter_test.go Add fixed width support for pprint reader (#1999) 2026-03-01 11:25:17 -05:00
line_reader.go Replace list.List with Go slices (#1950) 2026-02-01 17:22:28 -05:00
pseudo_reader_gen.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
README.md Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
record_reader.go Replace list.List with Go slices (#1950) 2026-02-01 17:22:28 -05:00
record_reader_benchmark_test.go Replace list.List with Go slices (#1950) 2026-02-01 17:22:28 -05:00
record_reader_csv.go EXPERIMENT (negative result): zero-copy CSV reader 2026-06-19 15:25:35 -04:00
record_reader_csvlite.go Batch-allocate per-record objects; reuse CSV writer field buffer 2026-06-19 12:27:22 -04:00
record_reader_dcf.go Add DCF (Debian Control Format) as supported file type (#1970) 2026-02-16 11:10:39 -05:00
record_reader_dkvp_nidx.go Batch-allocate per-record objects; reuse CSV writer field buffer 2026-06-19 12:27:22 -04:00
record_reader_dkvp_test.go The package version must match the major tag version (#1654) 2024-09-20 12:10:11 -04:00
record_reader_dkvpx.go Batch-allocate per-record objects; reuse CSV writer field buffer 2026-06-19 12:27:22 -04:00
record_reader_dkvpx_test.go Add DKVPX file format (#2002) 2026-03-02 22:35:08 -05:00
record_reader_factory.go Add DKVPX file format (#2002) 2026-03-02 22:35:08 -05:00
record_reader_json.go Performance and style fixes (#1981) 2026-02-18 09:19:31 -05:00
record_reader_markdown.go The package version must match the major tag version (#1654) 2024-09-20 12:10:11 -04:00
record_reader_pprint.go Batch-allocate per-record objects; reuse CSV writer field buffer 2026-06-19 12:27:22 -04:00
record_reader_tsv.go Batch-allocate per-record objects; reuse CSV writer field buffer 2026-06-19 12:27:22 -04:00
record_reader_xtab.go Batch-allocate per-record objects; reuse CSV writer field buffer 2026-06-19 12:27:22 -04:00
record_reader_yaml.go Support YAML I/O (#1963) 2026-02-15 09:24:38 -05:00
splitters.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00

Logic for parsing disk-file/standard-input byte streams into records.

There is one record-reader type per supported input file format, and a factory method.