-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add random read benchmarks for sst tables (#862)
* Add random read benchmarks for sst tables * Change table size in table benchmarks to 5 * 1e6 * Change table loading mode to `LoadToRAM` in table benchmarks * Update table/README to have latest benchmarks result.
- Loading branch information
1 parent
fa0679c
commit 88799d3
Showing
2 changed files
with
105 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,69 @@ | ||
# BenchmarkRead | ||
Size of table is 127,618,890 bytes for all benchmarks. | ||
|
||
# BenchmarkRead | ||
``` | ||
$ go test -bench Read$ -count 3 | ||
Size of table: 105843444 | ||
BenchmarkRead-8 3 343846914 ns/op | ||
BenchmarkRead-8 3 351790907 ns/op | ||
BenchmarkRead-8 3 351762823 ns/op | ||
$ go test -bench ^BenchmarkRead$ -run ^$ -count 3 | ||
goos: linux | ||
goarch: amd64 | ||
pkg: github.com/dgraph-io/badger/table | ||
BenchmarkRead-16 10 153281932 ns/op | ||
BenchmarkRead-16 10 153454443 ns/op | ||
BenchmarkRead-16 10 155349696 ns/op | ||
PASS | ||
ok github.com/dgraph-io/badger/table 23.549s | ||
``` | ||
|
||
Size of table is 105,843,444 bytes, which is ~101M. | ||
|
||
The rate is ~287M/s which matches our read speed. This is using mmap. | ||
Size of table is 127,618,890 bytes, which is ~122MB. | ||
|
||
To read a 64M table, this would take ~0.22s, which is negligible. | ||
The rate is ~783MB/s using LoadToRAM (when table is in RAM). | ||
|
||
``` | ||
$ go test -bench BenchmarkReadAndBuild -count 3 | ||
To read a 64MB table, this would take ~0.0817s, which is negligible. | ||
|
||
BenchmarkReadAndBuild-8 1 2341034225 ns/op | ||
BenchmarkReadAndBuild-8 1 2346349671 ns/op | ||
BenchmarkReadAndBuild-8 1 2364064576 ns/op | ||
# BenchmarkReadAndBuild | ||
```go | ||
$ go test -bench BenchmarkReadAndBuild -run ^$ -count 3 | ||
goos: linux | ||
goarch: amd64 | ||
pkg: github.com/dgraph-io/badger/table | ||
BenchmarkReadAndBuild-16 2 945041628 ns/op | ||
BenchmarkReadAndBuild-16 2 947120893 ns/op | ||
BenchmarkReadAndBuild-16 2 954909506 ns/op | ||
PASS | ||
ok github.com/dgraph-io/badger/table 26.856s | ||
``` | ||
|
||
The rate is ~43M/s. To build a ~64M table, this would take ~1.5s. Note that this | ||
The rate is ~127MB/s. To build a 64MB table, this would take ~0.5s. Note that this | ||
does NOT include the flushing of the table to disk. All we are doing above is | ||
to read one table (mmaped) and write one table in memory. | ||
reading one table (which is in RAM) and write one table in memory. | ||
|
||
The table building takes 0.5-0.0817s ~ 0.4183s. | ||
|
||
The table building takes 1.5-0.22 ~ 1.3s. | ||
# BenchmarkReadMerged | ||
Below, we merge 5 tables. The total size remains unchanged at ~122M. | ||
|
||
If we are writing out up to 10 tables, this would take 1.5*10 ~ 15s, and ~13s | ||
is spent building the tables. | ||
```go | ||
$ go test -bench ReadMerged -run ^$ -count 3 | ||
BenchmarkReadMerged-16 2 954475788 ns/op | ||
BenchmarkReadMerged-16 2 955252462 ns/op | ||
BenchmarkReadMerged-16 2 956857353 ns/op | ||
PASS | ||
ok github.com/dgraph-io/badger/table 33.327s | ||
``` | ||
|
||
When running populate, building one table in memory tends to take ~1.5s to ~2.5s | ||
on my system. Where does this overhead come from? Let's investigate the merging. | ||
The rate is ~127MB/s. To read a 64MB table using merge iterator, this would take ~0.5s. | ||
|
||
Below, we merge 5 tables. The total size remains unchanged at ~101M. | ||
# BenchmarkRandomRead | ||
|
||
``` | ||
$ go test -bench ReadMerged -count 3 | ||
BenchmarkReadMerged-8 1 1321190264 ns/op | ||
BenchmarkReadMerged-8 1 1296958737 ns/op | ||
BenchmarkReadMerged-8 1 1314381178 ns/op | ||
```go | ||
go test -bench BenchmarkRandomRead$ -run ^$ -count 3 | ||
goos: linux | ||
goarch: amd64 | ||
pkg: github.com/dgraph-io/badger/table | ||
BenchmarkRandomRead-16 300000 3596 ns/op | ||
BenchmarkRandomRead-16 300000 3621 ns/op | ||
BenchmarkRandomRead-16 300000 3596 ns/op | ||
PASS | ||
ok github.com/dgraph-io/badger/table 44.727s | ||
``` | ||
|
||
The rate is ~76M/s. To build a 64M table, this would take ~0.84s. The writing | ||
takes ~1.3s as we saw above. So in total, we expect around 0.84+1.3 ~ 2.1s. | ||
This roughly matches what we observe when running populate. There might be | ||
some additional overhead due to the concurrent writes going on, in flushing the | ||
table to disk. Also, the tables tend to be slightly bigger than 64M/s. | ||
For random read benchmarking, we are randomly reading a key and verifying its value. |
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