1BRC in Rust #57
Replies: 18 comments 43 replies
-
I had the same idea! Runs in https://github.com/PurpleMyst/1brc.rs/blob/main/src/main.rs |
Beta Was this translation helpful? Give feedback.
-
@coriolinus |
Beta Was this translation helpful? Give feedback.
-
@Lucretiel's version slightly modified, it runs under 10s => https://github.com/mtb0x1/1brc. I am pretty sure that we can speed it up by using custom hasher with Fxhashmap (make assumption about keys "city names", instead of comparing every bytes. check 2 firsts and 2 lasts or something similar) |
Beta Was this translation helpful? Give feedback.
-
I gave it a go, too. https://github.com/thebracket/one_billion_rows My biggest speedups came from using memmap2, chunking slices on a newline boundary, forward-only parsing (to keep each core's cache happy) and using one ahash map per thread - returning vectors for merging. Keying the hashmap on the slice of name bytes rather than a string of some sort helped a LOT. |
Beta Was this translation helpful? Give feedback.
-
Not yet (I actually generated my own input file) - that'll be tomorrow, ran
out of time for today.
…On Thu, Jan 4, 2024, 6:48 PM Corlin Palmer ***@***.***> wrote:
Did you check to see that your output was identical to the output of the
reference on the same file? If so, you might have the fastest solution
around!
—
Reply to this email directly, view it on GitHub
<#57 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADRU4365VBHFF3OVT3LQO4TYM5EXJAVCNFSM6AAAAABBL4UL32VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DAMJYGQ4DA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
~3.5s on M1 MAX Macbook Pro Strategy
Treat the first eight bytes of the name as a hash key into a fixed size 10k item hash table. Resolve collisions by finding the next unoccupied slot. Parse temperatures as Split input based on core count and run it with a thread per core. |
Beta Was this translation helpful? Give feedback.
-
Hi guys, https://github.com/gabrieledarrigo/1brc I'm learning the Rust basics, so my implementation is very naive (and quite OO) and uses a single thread. ~200s on a i7-3930K @3.20Ghx, with 64 GB of DD3 on Windows, running the binary on WSL.
If a kind soul would like to review my code I'll be grateful forever! |
Beta Was this translation helpful? Give feedback.
-
Hi, my attempt at the problem https://github.com/Namit-Nayan/one_billion_row |
Beta Was this translation helpful? Give feedback.
-
Hi, Here you can find my attempt: https://github.com/arthurlm/one-brc-rs I have explain in details my code and how I achieve this. I am also very curious of this program performances on any other computer. |
Beta Was this translation helpful? Give feedback.
-
Certainly late to the party, but here is my attempt none the less: https://github.com/GeistInDerSH/1brc |
Beta Was this translation helpful? Give feedback.
-
Never wrote any rust code in my life before this challenge. I broke the rules about not using external dependencies on this but anyway here's my code https://github.com/ANKerD/1brc It runs on about 15s on a Macbook air M1 8GB. I used an external heap allocator (mimalloc), FxHashpMap for faster HashMap access, itertools to iterate over the sorted keys, and used Profile-Guided Optimization for general 10~20% faster execution times. |
Beta Was this translation helpful? Give feedback.
-
A concise solution using rayon: Runs in 27s on ryzen 7 3800x. No optimizations were done other than adding The one-liner in main is just: fs::read_to_string("measurements.txt")?
.par_lines()
.flat_map(parse_line)
.fold(Stations::default, Stations::insert_line)
.reduce(Stations::default, Stations::merge)
.print(); |
Beta Was this translation helpful? Give feedback.
-
~50s on Ryzen 7 3700U 8 core 2.3 GH With using Mmap and thread pool. Implementation: I am open to your support and development ideas, please comment. |
Beta Was this translation helpful? Give feedback.
-
Can someone be nice enough to review my code. I am using pure |
Beta Was this translation helpful? Give feedback.
-
Update: Optimized float parsing and unchecked UTF8 str usage little bit more, it now completes the task in I'm able to parse measurements.txt correctly in I used libc, cityhash64 and Rust std. Feel free to test/roast my code: https://github.com/SuperioOne/1brc |
Beta Was this translation helpful? Give feedback.
-
Here's my attempt using only the Not many seems to mention the this: my SSD which is noted to have 3,500MB/s Seq. Read by the manufacturer would theoretically allow me to read the 14 GB file in ~4s, so attaining sub 1s is kind of a lost hope for now :') |
Beta Was this translation helpful? Give feedback.
-
I know I'm late to the game but here is my rusty solution: https://github.com/Cobinja/onebrc NOTE: Don't run this on 16GB machines, it reads the whole 13.8 GB to RAM. |
Beta Was this translation helpful? Give feedback.
-
Well this is my go at it. |
Beta Was this translation helpful? Give feedback.
-
Nothing too exciting - mmap whole file, split it into slices (one per core), collect partial results and merge.
Code is here: https://github.com/tumdum/1brc/blob/main/src/main.rs
Runs in ~15.5s on a m2pro
Beta Was this translation helpful? Give feedback.
All reactions