rocksdb/java/rocksjni
Hui Xiao 151242ce46 Group rocksdb.sst.read.micros stat by IOActivity flush and compaction (#11288)
Summary:
**Context:**
The existing stat rocksdb.sst.read.micros does not reflect each of compaction and flush cases but aggregate them, which is not so helpful for us to understand IO read behavior of each of them.

**Summary**
- Update `StopWatch` and `RandomAccessFileReader` to record `rocksdb.sst.read.micros` and `rocksdb.file.{flush/compaction}.read.micros`
   - Fixed the default histogram in `RandomAccessFileReader`
- New field `ReadOptions/IOOptions::io_activity`; Pass `ReadOptions` through paths under db open, flush and compaction to where we can prepare `IOOptions` and pass it to `RandomAccessFileReader`
- Use `thread_status_util` for assertion in `DbStressFSWrapper` for continuous testing on we are passing correct `io_activity` under db open, flush and compaction

Pull Request resolved: https://github.com/facebook/rocksdb/pull/11288

Test Plan:
- **Stress test**
- **Db bench 1: rocksdb.sst.read.micros COUNT ≈ sum of rocksdb.file.read.flush.micros's and rocksdb.file.read.compaction.micros's.**  (without blob)
     - May not be exactly the same due to `HistogramStat::Add` only guarantees atomic not accuracy across threads.
```
./db_bench -db=/dev/shm/testdb/ -statistics=true -benchmarks="fillseq" -key_size=32 -value_size=512 -num=50000 -write_buffer_size=655 -target_file_size_base=655 -disable_auto_compactions=false -compression_type=none -bloom_bits=3 (-use_plain_table=1 -prefix_size=10)
```
```
// BlockBasedTable
rocksdb.sst.read.micros P50 : 2.009374 P95 : 4.968548 P99 : 8.110362 P100 : 43.000000 COUNT : 40456 SUM : 114805
rocksdb.file.read.flush.micros P50 : 1.871841 P95 : 3.872407 P99 : 5.540541 P100 : 43.000000 COUNT : 2250 SUM : 6116
rocksdb.file.read.compaction.micros P50 : 2.023109 P95 : 5.029149 P99 : 8.196910 P100 : 26.000000 COUNT : 38206 SUM : 108689

// PlainTable
Does not apply
```
- **Db bench 2: performance**

**Read**

SETUP: db with 900 files
```
./db_bench -db=/dev/shm/testdb/ -benchmarks="fillseq" -key_size=32 -value_size=512 -num=50000 -write_buffer_size=655  -disable_auto_compactions=true -target_file_size_base=655 -compression_type=none
```run till convergence
```
./db_bench -seed=1678564177044286 -use_existing_db=true -db=/dev/shm/testdb -benchmarks=readrandom[-X60] -statistics=true -num=1000000 -disable_auto_compactions=true -compression_type=none -bloom_bits=3
```
Pre-change
`readrandom [AVG 60 runs] : 21568 (± 248) ops/sec`
Post-change (no regression, -0.3%)
`readrandom [AVG 60 runs] : 21486 (± 236) ops/sec`

**Compaction/Flush**run till convergence
```
./db_bench -db=/dev/shm/testdb2/ -seed=1678564177044286 -benchmarks="fillseq[-X60]" -key_size=32 -value_size=512 -num=50000 -write_buffer_size=655  -disable_auto_compactions=false -target_file_size_base=655 -compression_type=none

rocksdb.sst.read.micros  COUNT : 33820
rocksdb.sst.read.flush.micros COUNT : 1800
rocksdb.sst.read.compaction.micros COUNT : 32020
```
Pre-change
`fillseq [AVG 46 runs] : 1391 (± 214) ops/sec;    0.7 (± 0.1) MB/sec`

Post-change (no regression, ~-0.4%)
`fillseq [AVG 46 runs] : 1385 (± 216) ops/sec;    0.7 (± 0.1) MB/sec`

Reviewed By: ajkr

Differential Revision: D44007011

Pulled By: hx235

fbshipit-source-id: a54c89e4846dfc9a135389edf3f3eedfea257132
2023-04-21 09:07:18 -07:00
..
backup_engine_options.cc Fix remaining uses of "backupable" (#9792) 2022-04-05 09:52:33 -07:00
backupenginejni.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
cache.cc Put Cache and CacheWrapper in new public header (#11192) 2023-02-09 12:12:02 -08:00
cassandra_compactionfilterjni.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
cassandra_value_operator.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
checkpoint.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
clock_cache.cc Revert NewClockCache signature (#10358) 2022-07-13 17:43:39 -07:00
columnfamilyhandle.cc Replace namespace name "rocksdb" with ROCKSDB_NAMESPACE (#6433) 2020-02-20 12:09:57 -08:00
compact_range_options.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
compaction_filter.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
compaction_filter_factory.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
compaction_filter_factory_jnicallback.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
compaction_filter_factory_jnicallback.h Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
compaction_job_info.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
compaction_job_stats.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
compaction_options.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
compaction_options_fifo.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
compaction_options_universal.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
comparator.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
comparatorjnicallback.cc Fix Java API ComparatorOptions use after delete error (#11176) 2023-02-17 13:03:41 -08:00
comparatorjnicallback.h Fix Java API ComparatorOptions use after delete error (#11176) 2023-02-17 13:03:41 -08:00
compression_options.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
concurrent_task_limiter.cc Add some missing headers (#10519) 2022-08-11 12:45:50 -07:00
config_options.cc Remove deprecated util functions in options_util.h (#11126) 2023-01-27 11:10:53 -08:00
cplusplus_to_java_convert.h Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
env.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
env_options.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
event_listener.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
event_listener_jnicallback.cc Add (& fix) some simple source code checks (#8821) 2021-09-07 21:19:27 -07:00
event_listener_jnicallback.h Add (& fix) some simple source code checks (#8821) 2021-09-07 21:19:27 -07:00
filter.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
ingest_external_file_options.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
iterator.cc Extend Java RocksDB iterators to support indirect Byte Buffers (#9222) 2022-03-24 12:50:38 -07:00
jnicallback.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
jnicallback.h Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
loggerjnicallback.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
loggerjnicallback.h Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
lru_cache.cc Use the default metadata charge policy when creating an LRU cache via the Java API (#10577) 2022-08-29 09:42:04 -07:00
memory_util.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
memtablejni.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
merge_operator.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
native_comparator_wrapper_test.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
optimistic_transaction_db.cc RocksJava API - fix Transaction.multiGet() size limit, remove bogus EnsureLocalCapacity() calls (#10674) 2022-10-26 17:25:33 -07:00
optimistic_transaction_options.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
options.cc Remove a couple deprecated convenience.h APIs (#11120) 2023-02-07 14:11:53 -08:00
options_util.cc Remove deprecated util functions in options_util.h (#11126) 2023-01-27 11:10:53 -08:00
persistent_cache.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
portal.h Group rocksdb.sst.read.micros stat by IOActivity flush and compaction (#11288) 2023-04-21 09:07:18 -07:00
ratelimiterjni.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
remove_emptyvalue_compactionfilterjni.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
restorejni.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
rocks_callback_object.cc Fix tabs and lint-ignores (#6734) 2020-04-20 11:39:31 -07:00
rocksdb_exception_test.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
rocksjni.cc Improve Java API get() performance by reducing copies (#10970) 2022-12-21 11:54:24 -08:00
slice.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
snapshot.cc Replace namespace name "rocksdb" with ROCKSDB_NAMESPACE (#6433) 2020-02-20 12:09:57 -08:00
sst_file_manager.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
sst_file_reader_iterator.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
sst_file_readerjni.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
sst_file_writerjni.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
sst_partitioner.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
statistics.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
statisticsjni.cc Fix tabs and lint-ignores (#6734) 2020-04-20 11:39:31 -07:00
statisticsjni.h Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
table.cc Remove compressed block cache (#11117) 2023-01-24 17:09:19 -08:00
table_filter.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
table_filter_jnicallback.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
table_filter_jnicallback.h Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
testable_event_listener.cc Update build files for java8 build (#9541) 2022-02-17 13:29:21 -08:00
thread_status.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
trace_writer.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
trace_writer_jnicallback.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
trace_writer_jnicallback.h Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
transaction.cc RocksJava API - fix Transaction.multiGet() size limit, remove bogus EnsureLocalCapacity() calls (#10674) 2022-10-26 17:25:33 -07:00
transaction_db.cc RocksJava API - fix Transaction.multiGet() size limit, remove bogus EnsureLocalCapacity() calls (#10674) 2022-10-26 17:25:33 -07:00
transaction_db_options.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
transaction_log.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
transaction_notifier.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
transaction_notifier_jnicallback.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
transaction_notifier_jnicallback.h Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
transaction_options.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
ttl.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
wal_filter.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
wal_filter_jnicallback.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
wal_filter_jnicallback.h Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
write_batch.cc Fix pointer to jlong conversion in 32 bit OS (#9396) 2022-03-01 09:02:15 -08:00
write_batch_test.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
write_batch_with_index.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
write_buffer_manager.cc Put Cache and CacheWrapper in new public header (#11192) 2023-02-09 12:12:02 -08:00
writebatchhandlerjnicallback.cc Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00
writebatchhandlerjnicallback.h Run format check for *.h and *.cc files under java/ (#10851) 2022-10-25 09:26:51 -07:00