Revision 4a21b1402cb454f6e68d4c6f288d73700b3ff9db authored by Islam AbdelRahman on 01 December 2016, 21:30:01 UTC, committed by Facebook Github Bot on 01 December 2016, 21:39:14 UTC
Summary:
Reduce number of comparisons in heap by caching which child node in the first level is smallest (left_child or right_child)
So next time we can compare directly against the smallest child

I see that the total number of calls to comparator drops significantly when using this optimization

Before caching (~2mil key comparison for iterating the DB)
```
$ DEBUG_LEVEL=0 make db_bench -j64 && ./db_bench --benchmarks="readseq" --db="/dev/shm/heap_opt" --use_existing_db --disable_auto_compactions --cache_size=1000000000  --perf_level=2
readseq      :       0.338 micros/op 2959201 ops/sec;  327.4 MB/s user_key_comparison_count = 2000008
```
After caching (~1mil key comparison for iterating the DB)
```
$ DEBUG_LEVEL=0 make db_bench -j64 && ./db_bench --benchmarks="readseq" --db="/dev/shm/heap_opt" --use_existing_db --disable_auto_compactions --cache_size=1000000000 --perf_level=2
readseq      :       0.309 micros/op 3236801 ops/sec;  358.1 MB/s user_key_comparison_count = 1000011
```

It also improves
Closes https://github.com/facebook/rocksdb/pull/1600

Differential Revision: D4256027

Pulled By: IslamAbdelRahman

fbshipit-source-id: 76fcc66
1 parent e39d080
History
File Mode Size
dump
rdb
CMakeLists.txt -rw-r--r-- 544 bytes
Dockerfile -rw-r--r-- 81 bytes
auto_sanity_test.sh -rwxr-xr-x 2.6 KB
benchmark.sh -rwxr-xr-x 16.6 KB
benchmark_leveldb.sh -rwxr-xr-x 5.1 KB
check_format_compatible.sh -rwxr-xr-x 3.8 KB
db_bench.cc -rw-r--r-- 851 bytes
db_bench_tool.cc -rw-r--r-- 169.1 KB
db_bench_tool_test.cc -rw-r--r-- 9.7 KB
db_crashtest.py -rw-r--r-- 13.2 KB
db_repl_stress.cc -rw-r--r-- 4.5 KB
db_sanity_test.cc -rw-r--r-- 8.4 KB
db_stress.cc -rw-r--r-- 80.1 KB
dbench_monitor -rwxr-xr-x 2.6 KB
generate_random_db.sh -rwxr-xr-x 726 bytes
ldb.cc -rw-r--r-- 602 bytes
ldb_cmd.cc -rw-r--r-- 91.5 KB
ldb_cmd_impl.h -rw-r--r-- 13.4 KB
ldb_cmd_test.cc -rw-r--r-- 1.8 KB
ldb_test.py -rw-r--r-- 23.6 KB
ldb_tool.cc -rw-r--r-- 4.3 KB
pflag -rwxr-xr-x 4.0 KB
reduce_levels_test.cc -rw-r--r-- 5.2 KB
regression_test.sh -rwxr-xr-x 12.7 KB
rocksdb_dump_test.sh -rwxr-xr-x 325 bytes
run_flash_bench.sh -rwxr-xr-x 13.4 KB
run_leveldb.sh -rwxr-xr-x 6.2 KB
sample-dump.dmp -rw-r--r-- 100 bytes
sst_dump.cc -rw-r--r-- 611 bytes
sst_dump_test.cc -rw-r--r-- 6.4 KB
sst_dump_tool.cc -rw-r--r-- 19.8 KB
sst_dump_tool_imp.h -rw-r--r-- 2.6 KB
verify_random_db.sh -rwxr-xr-x 710 bytes
write_stress.cc -rw-r--r-- 10.8 KB
write_stress_runner.py -rw-r--r-- 2.2 KB

back to top