Skip to content

Commit

Permalink
Apporach 2: Remove redundant creation of Vector while reading line (T…
Browse files Browse the repository at this point in the history
…ime: 241s)

In the 'read_line' function, we split the line at ';' and then collect
the split data into a vector. This collection is redundant because we
discard this vector at the end of function.

The 'collect()' call has to make a system call to allocate some memory
on heap, and since we do this for 1 billion lines - the extra overhead
time for creating space for vector accumulates.

Instead of using 'collect()' we only split the line and use the
interators to extract the values. This removes the necessity of talking
to the OS.
  • Loading branch information
Naveenaidu committed Jul 14, 2024
1 parent 455609a commit fb2dda8
Show file tree
Hide file tree
Showing 3 changed files with 986 additions and 4 deletions.
Loading

0 comments on commit fb2dda8

Please sign in to comment.