Comparison with fast C++ csv parser

Open
#2,634 15 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp, r

Research direction

Review the linked readr proof-of-concept commit, the readr:::read_trip_fare and data.table::fread benchmark commands, and the fast C++ CSV parser it references. Compare the stated timings and parser assumptions first; the issue does not define a concrete implementation or completion criterion.

Written by the indexing model from the issue text.

Description

benchmark fread

In https://github.com/jimhester/readr/commit/33b793621c33b915e896fb3778c5a47152ccd73d @jimhester implements a proof-of-concept of https://github.com/ben-strasser/fast-cpp-csv-parser with impressive timings on a static 1.56 GB file (especially on the 'hot' second timing).

> system.time(y <- readr:::read_trip_fare(normalizePath("trip_fare_1.csv")))
   user  system elapsed 
  19.97    1.01   20.15 

> system.time(y <- data.table::fread(normalizePath("trip_fare_1.csv")))
|--------------------------------------------------|
|==================================================|
   user  system elapsed 
  23.88    0.75   18.24
 
> system.time(y <- readr:::read_trip_fare(normalizePath("trip_fare_1.csv")))
   user  system elapsed 
  12.81    1.08   12.91
 
> system.time(y <- data.table::fread(normalizePath("trip_fare_1.csv")))
|--------------------------------------------------|
|==================================================|
   user  system elapsed 
  24.36    0.66   17.92 


> dim(y)
[1] 14776615       11

The purpose of this issue is recognize its performance and broadcast awareness of this parser, to anticipate comparisons with fread and to gather what, if anything, can be learnt from this implementation. From what I understand, the function requires a lot of knowledge of the csv's structure well in advance of it being read. (In data.table parlance, perhaps, a 'fast and unfriendly file finagler'.) Nonetheless I believe there is a use-case for such a function: a kind-of plain-text cached version could be very valuable if fast.

Dominant language
R
Stars
3.9k
Forks
1.1k
Avg merge
14h 4m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Rdatatable/data.table

All issues in Rdatatable/data.table

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.