-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples: add a solution to the "1 Billion Row Challenge" (#23458)
- Loading branch information
Showing
5 changed files
with
705 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# 1 Billion Row Challenge (1BRC) | ||
|
||
A solution to the [1 Billion Row Challenge](https://www.morling.dev/blog/one-billion-row-challenge/), | ||
written in [the V programming language](https://vlang.io/). | ||
|
||
Read more about the challenge here: https://www.morling.dev/blog/one-billion-row-challenge/ | ||
|
||
|
||
## Running instructions | ||
|
||
Suggested compiler options for performance: | ||
|
||
`v -cc gcc -prod -cflags "-std=c17 -march=native -mtune=native" .` | ||
|
||
|
||
### Step 1: Create a measurements file | ||
|
||
Compile and run `make-samples` to create the sample file. | ||
|
||
``` | ||
cd make-samples | ||
v -cc gcc -prod -cflags "-std=c17 -march=native -mtune=native" . | ||
./make-samples 1000000000 > ~/measurements.txt | ||
``` | ||
|
||
NOTE: If you create a billion rows, the file will be about 12GB! | ||
|
||
### Step 2: Run (and time) the solution | ||
|
||
``` | ||
cd solution | ||
v -cc gcc -prod -cflags "-std=c17 -march=native -mtune=native" . | ||
./solution ~/measurements.txt | ||
``` | ||
|
||
You can time the solution using `v time`: | ||
|
||
`v time ./solution ~/measurements.txt` | ||
|
||
By default, the solution runs in a single thread. If you want to run | ||
parallel processing, use the `-n` parameter, for example, to run with | ||
8 threads: | ||
|
||
`./solution -n 8 ~/measurements.txt` | ||
|
||
On Linux, to run one thread per core, use | ||
|
||
`./solution -n $(nproc) ~/measurements.txt` | ||
|
||
### Step 3: Improve upon the solution | ||
|
||
Make changes that improve the performance and submit them. | ||
Let's show off what is possible in V! |
Oops, something went wrong.