Skip to content

Commit

Permalink
Approach 8: Use mmap and bytes everywhere (Time: 78s)
Browse files Browse the repository at this point in the history
In this appraoch we do two things:
1. Use mmap so that we can directly use bytes insted of depending on
   vectors
2. Replace all instances of Vec to bytes

We can see from the previous flamegraph that `to_vec` takes almost 14%
of the cycle in `read_line` function. The motivation to use mmap here
was to convert everything in bytes so that we can reduce the allocation
of memory on Heap for every line.

P.S: I hate the use of unsafe here, but I'm going with it for now and
plan to change it later once I make other stuff performant
  • Loading branch information
Naveenaidu committed Jul 14, 2024
1 parent 2bc8cc3 commit 38bdd01
Show file tree
Hide file tree
Showing 3 changed files with 515 additions and 25 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ rust_decimal = "1.34"
rust_decimal_macros = "1.34"
fast-float = "0.2"
rustc-hash = { version = "1.0"}
memmap2 = {version = "0.9.4"}
Loading

0 comments on commit 38bdd01

Please sign in to comment.