Revision 259a00eaca24105b285f3c328f7ae42822fa33a0 authored by Aaron Gao on 10 May 2017, 08:32:52 UTC, committed by Facebook Github Bot on 10 May 2017, 08:49:52 UTC
Summary:
Consider BlockReadAmpBitmap with bytes_per_bit = 32. Suppose bytes [a, b) were used, while bytes [a-32, a)
 and [b+1, b+33) weren't used; more formally, the union of ranges passed to BlockReadAmpBitmap::Mark() contains [a, b) and doesn't intersect with [a-32, a) and [b+1, b+33). Then bits [floor(a/32), ceil(b/32)] will be set, and so the number of useful bytes will be estimated as (ceil(b/32) - floor(a/32)) * 32, which is on average equal to b-a+31.

An extreme example: if we use 1 byte from each block, it'll be counted as 32 bytes from each block.

It's easy to remove this bias by slightly changing the semantics of the bitmap. Currently each bit represents a byte range [i*32, (i+1)*32).

This diff makes each bit represent a single byte: i*32 + X, where X is a random number in [0, 31] generated when bitmap is created. So, e.g., if you read a single byte at random, with probability 31/32 it won't be counted at all, and with probability 1/32 it will be counted as 32 bytes; so, on average it's counted as 1 byte.

*But there is one exception: the last bit will always set with the old way.*

(*) - assuming read_amp_bytes_per_bit = 32.
Closes https://github.com/facebook/rocksdb/pull/2259

Differential Revision: D5035652

Pulled By: lightmark

fbshipit-source-id: bd98b1b9b49fbe61f9e3781d07f624e3cbd92356
1 parent a620966
History
File Mode Size
aligned_buffer.h -rw-r--r-- 4.3 KB
allocator.h -rw-r--r-- 1.2 KB
arena.cc -rw-r--r-- 6.2 KB
arena.h -rw-r--r-- 5.1 KB
arena_test.cc -rw-r--r-- 6.5 KB
auto_roll_logger.cc -rw-r--r-- 5.6 KB
auto_roll_logger.h -rw-r--r-- 4.1 KB
auto_roll_logger_test.cc -rw-r--r-- 16.9 KB
autovector.h -rw-r--r-- 8.6 KB
autovector_test.cc -rw-r--r-- 9.5 KB
bloom.cc -rw-r--r-- 12.1 KB
bloom_test.cc -rw-r--r-- 7.4 KB
build_version.cc.in -rw-r--r-- 232 bytes
build_version.h -rw-r--r-- 772 bytes
channel.h -rw-r--r-- 1.7 KB
coding.cc -rw-r--r-- 2.5 KB
coding.h -rw-r--r-- 12.4 KB
coding_test.cc -rw-r--r-- 5.9 KB
compaction_job_stats_impl.cc -rw-r--r-- 2.3 KB
comparator.cc -rw-r--r-- 3.9 KB
compression.h -rw-r--r-- 25.0 KB
concurrent_arena.cc -rw-r--r-- 1.8 KB
concurrent_arena.h -rw-r--r-- 6.8 KB
crc32c.cc -rw-r--r-- 17.1 KB
crc32c.h -rw-r--r-- 1.8 KB
crc32c_test.cc -rw-r--r-- 2.2 KB
delete_scheduler.cc -rw-r--r-- 6.5 KB
delete_scheduler.h -rw-r--r-- 3.4 KB
delete_scheduler_test.cc -rw-r--r-- 18.9 KB
dynamic_bloom.cc -rw-r--r-- 2.7 KB
dynamic_bloom.h -rw-r--r-- 6.5 KB
dynamic_bloom_test.cc -rw-r--r-- 9.9 KB
event_logger.cc -rw-r--r-- 1.9 KB
event_logger.h -rw-r--r-- 4.7 KB
event_logger_test.cc -rw-r--r-- 1.4 KB
fault_injection_test_env.cc -rw-r--r-- 9.4 KB
fault_injection_test_env.h -rw-r--r-- 5.0 KB
file_reader_writer.cc -rw-r--r-- 18.2 KB
file_reader_writer.h -rw-r--r-- 6.2 KB
file_reader_writer_test.cc -rw-r--r-- 8.1 KB
file_util.cc -rw-r--r-- 3.0 KB
file_util.h -rw-r--r-- 1.1 KB
filelock_test.cc -rw-r--r-- 1.5 KB
filename.cc -rw-r--r-- 12.5 KB
filename.h -rw-r--r-- 6.7 KB
filter_policy.cc -rw-r--r-- 771 bytes
hash.cc -rw-r--r-- 2.6 KB
hash.h -rw-r--r-- 1.2 KB
hash_map.h -rw-r--r-- 1.9 KB
heap.h -rw-r--r-- 5.0 KB
heap_test.cc -rw-r--r-- 4.0 KB
kv_map.h -rw-r--r-- 1.1 KB
log_buffer.cc -rw-r--r-- 2.6 KB
log_buffer.h -rw-r--r-- 1.8 KB
log_write_bench.cc -rw-r--r-- 2.6 KB
logging.h -rw-r--r-- 2.3 KB
memory_usage.h -rw-r--r-- 1017 bytes
murmurhash.cc -rw-r--r-- 4.2 KB
murmurhash.h -rw-r--r-- 1.5 KB
mutexlock.h -rw-r--r-- 3.4 KB
random.cc -rw-r--r-- 1.1 KB
random.h -rw-r--r-- 3.6 KB
rate_limiter.cc -rw-r--r-- 8.3 KB
rate_limiter.h -rw-r--r-- 3.0 KB
rate_limiter_test.cc -rw-r--r-- 5.5 KB
slice.cc -rw-r--r-- 5.7 KB
slice_transform_test.cc -rw-r--r-- 4.5 KB
sst_file_manager_impl.cc -rw-r--r-- 5.3 KB
sst_file_manager_impl.h -rw-r--r-- 3.6 KB
status.cc -rw-r--r-- 3.0 KB
status_message.cc -rw-r--r-- 981 bytes
stderr_logger.h -rw-r--r-- 1023 bytes
stop_watch.h -rw-r--r-- 2.5 KB
string_util.cc -rw-r--r-- 9.3 KB
string_util.h -rw-r--r-- 4.4 KB
sync_point.cc -rw-r--r-- 4.6 KB
sync_point.h -rw-r--r-- 5.2 KB
testharness.cc -rw-r--r-- 1.4 KB
testharness.h -rw-r--r-- 1.5 KB
testutil.cc -rw-r--r-- 13.1 KB
testutil.h -rw-r--r-- 23.0 KB
thread_list_test.cc -rw-r--r-- 11.9 KB
thread_local.cc -rw-r--r-- 18.7 KB
thread_local.h -rw-r--r-- 3.5 KB
thread_local_test.cc -rw-r--r-- 14.6 KB
thread_operation.h -rw-r--r-- 3.9 KB
threadpool_imp.cc -rw-r--r-- 11.9 KB
threadpool_imp.h -rw-r--r-- 3.6 KB
transaction_test_util.cc -rw-r--r-- 6.8 KB
transaction_test_util.h -rw-r--r-- 4.0 KB
xxhash.cc -rw-r--r-- 15.2 KB
xxhash.h -rw-r--r-- 6.2 KB

back to top