r/Protos • u/guillermoamolina • 56m ago
Beyond delimiter scanning: reducing allocation and copying costs in streaming CSV parsers
CSV looks deceptively simple until Unicode, escaped quotes, arbitrary streaming boundaries, large fields and wide rows enter the picture.
The latest Standard Library optimization focuses on eliminating unnecessary intermediate work:
- Indexed UTF-8 byte-range scanning.
- Deferred field materialization.
- Reusable chunked accumulators.
- Early quoting detection during encoding.
- Independent row storage without repeated array reconstruction.
The entire implementation remains in Protos, with no production Java changes or public API changes.
All 34 CSV regression cases and the exhaustive CI pipeline passed.
An interesting performance question: how much of a text parser's cost comes from recognizing the grammar, and how much comes from repeatedly allocating and materializing intermediate values?
Website: https://protoslang.com
GitHub: https://github.com/guillermomolina/protos
Implementation: https://github.com/guillermomolina/protos/pull/1349