Skip to content

CSV Parser 5.0.0: Gigabytes Per Second

Choose a tag to compare

@vincentlaucsb vincentlaucsb released this 08 May 07:20
· 113 commits to master since this release

Version 5.0 (started on Cinco de Mayo) latest version implements true parallel CSV parsing with an arbitrary number of threads.

The numbers (documented in the README and under /benchmarks) have been incredible. I've thrown various different files at this parser and it chews through them at a rate of at least a gigabyte per second, even on a Intel Core i5 from 2022.

This was accomplished by implementing a speculative CSV parsing algorithm described in SIGMOD 2019, which essentially guesses (speculates) whether or not a CSV chunk was cut off in the middle of a quoted or unquoted field. This guess is 99.9% accurate, which allows us to safely parse chunks in parallel. In the case it is wrong, we fall back to the usual algorithm for parsing CSVs. Based on my testing, fallbacks do happen, but they are very rare (and is well-tested).

Threading Control

  • Speculative CSV parsing kicks in for files 50 MB or larger
  • Threading may be turned off entirely at runtime
    • If threading is enabled, a background parsing thread is still used for all inputs

Benchmarks

fast-cpp-csv-parser is still better for single-threaded performance. However, we achieve parity at about 2 threads and attain superior performance at 4+ threads.

What's Changed

New Contributors

Full Changelog: 4.1.0...5.0.0