rocksdb/table/block_based
haoyuhuang 5efa0d6b0d Create a BlockCacheLookupContext to enable fine-grained block cache tracing. (#5421)
Summary:
BlockCacheLookupContext only contains the caller for now.
We will trace block accesses at five places:
1. BlockBasedTable::GetFilter.
2. BlockBasedTable::GetUncompressedDict.
3. BlockBasedTable::MaybeReadAndLoadToCache. (To trace access on data, index, and range deletion block.)
4. BlockBasedTable::Get. (To trace the referenced key and whether the referenced key exists in a fetched data block.)
5. BlockBasedTable::MultiGet. (To trace the referenced key and whether the referenced key exists in a fetched data block.)

We create the context at:
1. BlockBasedTable::Get. (kUserGet)
2. BlockBasedTable::MultiGet. (kUserMGet)
3. BlockBasedTable::NewIterator. (either kUserIterator, kCompaction, or external SST ingestion calls this function.)
4. BlockBasedTable::Open. (kPrefetch)
5. Index/Filter::CacheDependencies. (kPrefetch)
6. BlockBasedTable::ApproximateOffsetOf. (kCompaction or kUserApproximateSize).

I loaded 1 million key-value pairs into the database and ran the readrandom benchmark with a single thread. I gave the block cache 10 GB to make sure all reads hit the block cache after warmup. The throughput is comparable.
Throughput of this PR: 231334 ops/s.
Throughput of the master branch: 238428 ops/s.

Experiment setup:
RocksDB:    version 6.2
Date:       Mon Jun 10 10:42:51 2019
CPU:        24 * Intel Core Processor (Skylake)
CPUCache:   16384 KB
Keys:       20 bytes each
Values:     100 bytes each (100 bytes after compression)
Entries:    1000000
Prefix:    20 bytes
Keys per prefix:    0
RawSize:    114.4 MB (estimated)
FileSize:   114.4 MB (estimated)
Write rate: 0 bytes/second
Read rate: 0 ops/second
Compression: NoCompression
Compression sampling rate: 0
Memtablerep: skip_list
Perf Level: 1

Load command: ./db_bench --benchmarks="fillseq" --key_size=20 --prefix_size=20 --keys_per_prefix=0 --value_size=100 --statistics --cache_index_and_filter_blocks --cache_size=10737418240 --disable_auto_compactions=1 --disable_wal=1 --compression_type=none --min_level_to_compress=-1 --compression_ratio=1 --num=1000000

Run command: ./db_bench --benchmarks="readrandom,stats" --use_existing_db --threads=1 --duration=120 --key_size=20 --prefix_size=20 --keys_per_prefix=0 --value_size=100 --statistics --cache_index_and_filter_blocks --cache_size=10737418240 --disable_auto_compactions=1 --disable_wal=1 --compression_type=none --min_level_to_compress=-1 --compression_ratio=1 --num=1000000 --duration=120

TODOs:
1. Create a caller for external SST file ingestion and differentiate the callers for iterator.
2. Integrate tracer to trace block cache accesses.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5421

Differential Revision: D15704258

Pulled By: HaoyuHuang

fbshipit-source-id: 4aa8a55f8cb1576ffb367bfa3186a91d8f06d93a
2019-06-10 15:33:27 -07:00
..
block.cc Move some logging related files to logging/ (#5387) 2019-05-31 17:23:59 -07:00
block.h Reuse data block iterator in BlockBasedTableReader::MultiGet() (#5314) 2019-06-10 13:31:19 -07:00
block_based_filter_block.cc Create a BlockCacheLookupContext to enable fine-grained block cache tracing. (#5421) 2019-06-10 15:33:27 -07:00
block_based_filter_block.h Create a BlockCacheLookupContext to enable fine-grained block cache tracing. (#5421) 2019-06-10 15:33:27 -07:00
block_based_filter_block_test.cc Create a BlockCacheLookupContext to enable fine-grained block cache tracing. (#5421) 2019-06-10 15:33:27 -07:00
block_based_table_builder.cc Add support for timestamp in Get/Put (#5079) 2019-06-05 23:10:47 -07:00
block_based_table_builder.h Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
block_based_table_factory.cc simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
block_based_table_factory.h Organizing rocksdb/table directory by format 2019-05-30 14:51:11 -07:00
block_based_table_reader.cc Create a BlockCacheLookupContext to enable fine-grained block cache tracing. (#5421) 2019-06-10 15:33:27 -07:00
block_based_table_reader.h Create a BlockCacheLookupContext to enable fine-grained block cache tracing. (#5421) 2019-06-10 15:33:27 -07:00
block_builder.cc Organizing rocksdb/table directory by format 2019-05-30 14:51:11 -07:00
block_builder.h Organizing rocksdb/table directory by format 2019-05-30 14:51:11 -07:00
block_prefix_index.cc Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
block_prefix_index.h Organizing rocksdb/table directory by format 2019-05-30 14:51:11 -07:00
block_test.cc Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
block_type.h Refactor the handling of cache related counters and statistics (#5408) 2019-06-06 11:36:40 -07:00
cachable_entry.h Organizing rocksdb/table directory by format 2019-05-30 14:51:11 -07:00
data_block_footer.cc Organizing rocksdb/table directory by format 2019-05-30 14:51:11 -07:00
data_block_footer.h Organizing rocksdb/table directory by format 2019-05-30 14:51:11 -07:00
data_block_hash_index.cc Organizing rocksdb/table directory by format 2019-05-30 14:51:11 -07:00
data_block_hash_index.h Organizing rocksdb/table directory by format 2019-05-30 14:51:11 -07:00
data_block_hash_index_test.cc Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
filter_block.h Create a BlockCacheLookupContext to enable fine-grained block cache tracing. (#5421) 2019-06-10 15:33:27 -07:00
flush_block_policy.cc Organizing rocksdb/table directory by format 2019-05-30 14:51:11 -07:00
flush_block_policy.h Organizing rocksdb/table directory by format 2019-05-30 14:51:11 -07:00
full_filter_block.cc Create a BlockCacheLookupContext to enable fine-grained block cache tracing. (#5421) 2019-06-10 15:33:27 -07:00
full_filter_block.h Create a BlockCacheLookupContext to enable fine-grained block cache tracing. (#5421) 2019-06-10 15:33:27 -07:00
full_filter_block_test.cc Create a BlockCacheLookupContext to enable fine-grained block cache tracing. (#5421) 2019-06-10 15:33:27 -07:00
index_builder.cc simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
index_builder.h simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
partitioned_filter_block.cc Create a BlockCacheLookupContext to enable fine-grained block cache tracing. (#5421) 2019-06-10 15:33:27 -07:00
partitioned_filter_block.h Create a BlockCacheLookupContext to enable fine-grained block cache tracing. (#5421) 2019-06-10 15:33:27 -07:00
partitioned_filter_block_test.cc Create a BlockCacheLookupContext to enable fine-grained block cache tracing. (#5421) 2019-06-10 15:33:27 -07:00