mirror of https://github.com/facebook/rocksdb.git
39f5846ec7
Summary: We want to know more about opportunities for better range filters, and the effectiveness of our own range filters. Currently the stats are very limited, essentially logging just hits and misses against prefix filters for range scans in BLOOM_FILTER_PREFIX_* without tracking the false positive rate. Perhaps confusingly, when prefix filters are used for point queries, the stats are currently going into the non-PREFIX tickers. This change does several things: * Introduce new stat tickers for seeks and related filtering, \*LEVEL_SEEK\* * Most importantly, allows us to see opportunities for range filtering. Specifically, we can count how many times a seek in an SST file accesses at least one data block, and how many times at least one value() is then accessed. If a data block was accessed but no value(), we can generally assume that the key(s) seen was(were) not of interest so could have been filtered with the right kind of filter, avoiding the data block access. * We can get the same level of detail when a filter (for now, prefix Bloom/ribbon) is used, or not. Specifically, we can infer a false positive rate for prefix filters (not available before) from the seek "false positive" rate: when a data block is accessed but no value() is called. (There can be other explanations for a seek false positive, but in typical iterator usage it would indicate a filter false positive.) * For efficiency, I wanted to avoid making additional calls to the prefix extractor (or key comparisons, etc.), which would be required if we wanted to more precisely detect filter false positives. I believe that instrumenting value() is the best balance of efficiency vs. accurately measuring what we are often interested in. * The stats are divided between last level and non-last levels, to help understand potential tiered storage use cases. * The old BLOOM_FILTER_PREFIX_* stats have a different meaning: no longer referring to iterators but to point queries using prefix filters. BLOOM_FILTER_PREFIX_TRUE_POSITIVE is added for computing the prefix false positive rate on point queries, which can be due to filter false positives as well as different keys with the same prefix. * Similarly, the non-PREFIX BLOOM_FILTER stats are now for whole key filtering only. Pull Request resolved: https://github.com/facebook/rocksdb/pull/11460 Test Plan: unit tests updated, including updating many to pop the stat value since last read to improve test readability and maintainability. Performance test shows a consistent small improvement with these changes, both with clang and with gcc. CPU profile indicates that RecordTick is using less CPU, and this makes sense at least for a high filter miss rate. Before, we were recording two ticks per filter miss in iterators (CHECKED & USEFUL) and now recording just one (FILTERED). Create DB with ``` TEST_TMPDIR=/dev/shm ./db_bench -benchmarks=fillrandom -num=10000000 -disable_wal=1 -write_buffer_size=30000000 -bloom_bits=8 -compaction_style=2 -fifo_compaction_max_table_files_size_mb=10000 -fifo_compaction_allow_compaction=0 -prefix_size=8 ``` And run simultaneous before&after with ``` TEST_TMPDIR=/dev/shm ./db_bench -readonly -benchmarks=seekrandom[-X1000] -num=10000000 -bloom_bits=8 -compaction_style=2 -fifo_compaction_max_table_files_size_mb=10000 -fifo_compaction_allow_compaction=0 -prefix_size=8 -seek_nexts=1 -duration=20 -seed=43 -threads=8 -cache_size=1000000000 -statistics ``` Before: seekrandom [AVG 275 runs] : 189680 (± 222) ops/sec; 18.4 (± 0.0) MB/sec After: seekrandom [AVG 275 runs] : 197110 (± 208) ops/sec; 19.1 (± 0.0) MB/sec Reviewed By: ajkr Differential Revision: D46029177 Pulled By: pdillinger fbshipit-source-id: cdace79a2ea548d46c5900b068c5b7c3a02e5822 |
||
---|---|---|
.. | ||
aligned_buffer.h | ||
async_file_reader.cc | ||
async_file_reader.h | ||
autovector.h | ||
autovector_test.cc | ||
bloom_impl.h | ||
bloom_test.cc | ||
build_version.cc.in | ||
cast_util.h | ||
channel.h | ||
cleanable.cc | ||
coding.cc | ||
coding.h | ||
coding_lean.h | ||
coding_test.cc | ||
compaction_job_stats_impl.cc | ||
comparator.cc | ||
compression.cc | ||
compression.h | ||
compression_context_cache.cc | ||
compression_context_cache.h | ||
concurrent_task_limiter_impl.cc | ||
concurrent_task_limiter_impl.h | ||
core_local.h | ||
coro_utils.h | ||
crc32c.cc | ||
crc32c.h | ||
crc32c_arm64.cc | ||
crc32c_arm64.h | ||
crc32c_ppc.c | ||
crc32c_ppc.h | ||
crc32c_ppc_asm.S | ||
crc32c_ppc_constants.h | ||
crc32c_test.cc | ||
data_structure.cc | ||
defer.h | ||
defer_test.cc | ||
distributed_mutex.h | ||
duplicate_detector.h | ||
dynamic_bloom.cc | ||
dynamic_bloom.h | ||
dynamic_bloom_test.cc | ||
fastrange.h | ||
file_checksum_helper.cc | ||
file_checksum_helper.h | ||
file_reader_writer_test.cc | ||
filelock_test.cc | ||
filter_bench.cc | ||
gflags_compat.h | ||
hash.cc | ||
hash.h | ||
hash128.h | ||
hash_containers.h | ||
hash_map.h | ||
hash_test.cc | ||
heap.h | ||
heap_test.cc | ||
kv_map.h | ||
log_write_bench.cc | ||
math.h | ||
math128.h | ||
murmurhash.cc | ||
murmurhash.h | ||
mutexlock.h | ||
ppc-opcode.h | ||
random.cc | ||
random.h | ||
random_test.cc | ||
rate_limiter.cc | ||
rate_limiter_impl.h | ||
rate_limiter_test.cc | ||
repeatable_thread.h | ||
repeatable_thread_test.cc | ||
ribbon_alg.h | ||
ribbon_config.cc | ||
ribbon_config.h | ||
ribbon_impl.h | ||
ribbon_test.cc | ||
set_comparator.h | ||
single_thread_executor.h | ||
slice.cc | ||
slice_test.cc | ||
slice_transform_test.cc | ||
status.cc | ||
stderr_logger.cc | ||
stderr_logger.h | ||
stop_watch.h | ||
string_util.cc | ||
string_util.h | ||
thread_guard.h | ||
thread_list_test.cc | ||
thread_local.cc | ||
thread_local.h | ||
thread_local_test.cc | ||
thread_operation.h | ||
threadpool_imp.cc | ||
threadpool_imp.h | ||
timer.h | ||
timer_queue.h | ||
timer_queue_test.cc | ||
timer_test.cc | ||
udt_util.h | ||
user_comparator_wrapper.h | ||
vector_iterator.h | ||
work_queue.h | ||
work_queue_test.cc | ||
xxhash.cc | ||
xxhash.h | ||
xxph3.h |