rocksdb/include/rocksdb
Aaron Gao 5d660258e7 add simulator Cache as class SimCache/SimLRUCache(with test)
Summary: add class SimCache(base class with instrumentation api) and SimLRUCache(derived class with detailed implementation) which is used as an instrumented block cache that can predict hit rate for different cache size

Test Plan:
Add a test case in `db_block_cache_test.cc` called `SimCacheTest` to test basic logic of SimCache.
Also add option `-simcache_size` in db_bench. if set with a value other than -1, then the benchmark will use this value as the size of the simulator cache and finally output the simulation result.
```
[gzh@dev9927.prn1 ~/local/rocksdb] ./db_bench -benchmarks "fillseq,readrandom" -cache_size 1000000 -simcache_size 1000000
RocksDB:    version 4.8
Date:       Tue May 17 16:56:16 2016
CPU:        32 * Intel(R) Xeon(R) CPU E5-2660 0 @ 2.20GHz
CPUCache:   20480 KB
Keys:       16 bytes each
Values:     100 bytes each (50 bytes after compression)
Entries:    1000000
Prefix:    0 bytes
Keys per prefix:    0
RawSize:    110.6 MB (estimated)
FileSize:   62.9 MB (estimated)
Write rate: 0 bytes/second
Compression: Snappy
Memtablerep: skip_list
Perf Level: 0
WARNING: Assertions are enabled; benchmarks unnecessarily slow
------------------------------------------------
DB path: [/tmp/rocksdbtest-112628/dbbench]
fillseq      :       6.809 micros/op 146874 ops/sec;   16.2 MB/s
DB path: [/tmp/rocksdbtest-112628/dbbench]
readrandom   :       6.343 micros/op 157665 ops/sec;   17.4 MB/s (1000000 of 1000000 found)

SIMULATOR CACHE STATISTICS:
SimCache LOOKUPs: 986559
SimCache HITs:    264760
SimCache HITRATE: 26.84%

[gzh@dev9927.prn1 ~/local/rocksdb] ./db_bench -benchmarks "fillseq,readrandom" -cache_size 1000000 -simcache_size 10000000
RocksDB:    version 4.8
Date:       Tue May 17 16:57:10 2016
CPU:        32 * Intel(R) Xeon(R) CPU E5-2660 0 @ 2.20GHz
CPUCache:   20480 KB
Keys:       16 bytes each
Values:     100 bytes each (50 bytes after compression)
Entries:    1000000
Prefix:    0 bytes
Keys per prefix:    0
RawSize:    110.6 MB (estimated)
FileSize:   62.9 MB (estimated)
Write rate: 0 bytes/second
Compression: Snappy
Memtablerep: skip_list
Perf Level: 0
WARNING: Assertions are enabled; benchmarks unnecessarily slow
------------------------------------------------
DB path: [/tmp/rocksdbtest-112628/dbbench]
fillseq      :       5.066 micros/op 197394 ops/sec;   21.8 MB/s
DB path: [/tmp/rocksdbtest-112628/dbbench]
readrandom   :       6.457 micros/op 154870 ops/sec;   17.1 MB/s (1000000 of 1000000 found)

SIMULATOR CACHE STATISTICS:
SimCache LOOKUPs: 1059764
SimCache HITs:    374501
SimCache HITRATE: 35.34%

[gzh@dev9927.prn1 ~/local/rocksdb] ./db_bench -benchmarks "fillseq,readrandom" -cache_size 1000000 -simcache_size 100000000
RocksDB:    version 4.8
Date:       Tue May 17 16:57:32 2016
CPU:        32 * Intel(R) Xeon(R) CPU E5-2660 0 @ 2.20GHz
CPUCache:   20480 KB
Keys:       16 bytes each
Values:     100 bytes each (50 bytes after compression)
Entries:    1000000
Prefix:    0 bytes
Keys per prefix:    0
RawSize:    110.6 MB (estimated)
FileSize:   62.9 MB (estimated)
Write rate: 0 bytes/second
Compression: Snappy
Memtablerep: skip_list
Perf Level: 0
WARNING: Assertions are enabled; benchmarks unnecessarily slow
------------------------------------------------
DB path: [/tmp/rocksdbtest-112628/dbbench]
fillseq      :       5.632 micros/op 177572 ops/sec;   19.6 MB/s
DB path: [/tmp/rocksdbtest-112628/dbbench]
readrandom   :       6.892 micros/op 145094 ops/sec;   16.1 MB/s (1000000 of 1000000 found)

SIMULATOR CACHE STATISTICS:
SimCache LOOKUPs: 1150767
SimCache HITs:    1034535
SimCache HITRATE: 89.90%
```

Reviewers: IslamAbdelRahman, andrewkr, sdong

Reviewed By: sdong

Subscribers: MarkCallaghan, andrewkr, dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D57999
2016-05-23 23:35:23 -07:00
..
utilities add simulator Cache as class SimCache/SimLRUCache(with test) 2016-05-23 23:35:23 -07:00
c.h Expose report_bg_io_stats option in the C API. (#1131) 2016-05-23 13:13:47 -07:00
cache.h add simulator Cache as class SimCache/SimLRUCache(with test) 2016-05-23 23:35:23 -07:00
compaction_filter.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
compaction_job_stats.h Rename options.compaction_measure_io_stats to options.report_bg_io_stats and include flush too. 2016-04-15 10:22:18 -07:00
comparator.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
convenience.h Add GetStringFromCompressionType to include/rocksdb/convenience.h 2016-05-18 15:03:21 -07:00
db_bench_tool.h Separeate main from bench functionality to allow cusomizations 2016-02-16 06:17:31 -08:00
db_dump_tool.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
db.h Add per-level compression ratio property 2016-04-20 18:46:54 -07:00
env.h Direct IO capability for RocksDB 2016-05-23 12:27:27 -07:00
experimental.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
filter_policy.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
flush_block_policy.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
immutable_options.h [rocksdb] make more options dynamic 2016-05-17 13:11:56 -07:00
iostats_context.h IOStatsContext::ToString() add option to exclude zero counters 2016-02-23 10:26:24 -08:00
iterator.h Introduce PinnedIteratorsManager (Reduce PinData() overhead / Refactor PinData) 2016-04-26 12:41:07 -07:00
ldb_tool.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
listener.h Add bottommost_compression option 2016-05-09 15:57:19 -07:00
memtablerep.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
merge_operator.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
metadata.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
options.h Added PersistentCache abstraction 2016-05-15 22:17:18 -07:00
perf_context.h Update comments on include/rocksdb/perf_context.h 2016-04-08 11:27:08 -07:00
perf_level.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
persistent_cache.h Added PersistentCache abstraction 2016-05-15 22:17:18 -07:00
rate_limiter.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
slice_transform.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
slice.h to/from hex refactor 2016-03-30 14:36:48 -07:00
snapshot.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
sst_dump_tool.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
sst_file_manager.h Introduce SstFileManager::SetMaxAllowedSpaceUsage() to cap disk space usage 2016-02-17 15:20:23 -08:00
sst_file_writer.h [rocksdb] make more options dynamic 2016-05-17 13:11:56 -07:00
statistics.h Added PersistentCache abstraction 2016-05-15 22:17:18 -07:00
status.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
table_properties.h Added "number of merge operands" to statistics in ssts. 2016-05-19 14:24:48 -07:00
table.h Deprecate BlockBasedTableOptions.hash_index_allow_collision=false. 2016-05-20 17:52:27 -07:00
thread_status.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
transaction_log.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
types.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
universal_compaction.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
version.h Release RocksDB 4.8.0 2016-05-02 14:38:04 -07:00
wal_filter.h Avoid overloaded virtual function 2016-03-22 17:10:31 -07:00
write_batch_base.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
write_batch.h Modification of WriteBatch to support two phase commit 2016-05-10 14:06:07 -07:00