Skip to content

CSV Parser 5.0.0 Beta: Let's Get Parallel Round 2

Pre-release
Pre-release

Choose a tag to compare

@vincentlaucsb vincentlaucsb released this 05 May 07:00
· 116 commits to master since this release
1fc5331

Overview

Until now, csv-parser used a single threaded DFA state machine. While we used a single producer-single consumer queue that allowed the parsing to happen in a background thread without blocking the main thread, the parsing was fundamentally single threaded.

The core problem was the CSV chunks could not simply be split by newline, since CSV fields may contain embedded newlines.

However, the paper below, presented at ACM's SIGMOD 2019 conference presented a speculative algorithm which reliably allows us to safely parse CSVs in parallel. This version implements that paper on top of the existing DFA parsing algorithm.

I will not go into the paper more since I am tired. I will save the full explanation for the full 5.0.0 release.

Why Beta?

I decided to release this as 5.0.0-beta because the internal code is a bit spaghetti-ish and I'd like to do more testing to verify no performance regressions on the single threaded path.

However, the tests are all green and the performance gains are too good to keep hidden in an unmerged PR.

  • 11GB metadata.tsv parsed in 13 seconds on a cold run (900 MB/s)
  • 1.4 Used Vehicles data set: 1.4s cold, 0.48s hot (more than twice as fast as the current README numbers)

I encourage users with multi-core CPUs to try this out!

References

Chang Ge, Yinan Li, Eric Eilebrecht, Badrish Chandramouli, and Donald Kossmann.
“Speculative Distributed CSV Data Parsing for Big Data Analytics.”
Proceedings of the 2019 ACM SIGMOD International Conference on Management of Data (SIGMOD ’19), 2019.

https://www.microsoft.com/en-us/research/publication/speculative-distributed-csv-data-parsing-for-big-data-analytics/

What's Changed

Full Changelog: 4.1.0...5.0.0-beta