rocksdb/db_stress_tool
Hui Xiao a5d773e077 Add rate-limiting support to batched MultiGet() (#10159)
Summary:
**Context/Summary:**
https://github.com/facebook/rocksdb/pull/9424 added rate-limiting support for user reads, which does not include batched `MultiGet()`s that call `RandomAccessFileReader::MultiRead()`. The reason is that it's harder (compared with RandomAccessFileReader::Read()) to implement the ideal rate-limiting where we first call `RateLimiter::RequestToken()` for allowed bytes to multi-read and then consume those bytes by satisfying as many requests in `MultiRead()` as possible. For example, it can be tricky to decide whether we want partially fulfilled requests within one `MultiRead()` or not.

However, due to a recent urgent user request, we decide to pursue an elementary (but a conditionally ineffective) solution where we accumulate enough rate limiter requests toward the total bytes needed by one `MultiRead()` before doing that `MultiRead()`. This is not ideal when the total bytes are huge as we will actually consume a huge bandwidth from rate-limiter causing a burst on disk. This is not what we ultimately want with rate limiter. Therefore a follow-up work is noted through TODO comments.

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

Test Plan:
- Modified existing unit test `DBRateLimiterOnReadTest/DBRateLimiterOnReadTest.NewMultiGet`
- Traced the underlying system calls `io_uring_enter` and verified they are 10 seconds apart from each other correctly under the setting of  `strace -ftt -e trace=io_uring_enter ./db_bench -benchmarks=multireadrandom -db=/dev/shm/testdb2 -readonly -num=50 -threads=1 -multiread_batched=1 -batch_size=100 -duration=10 -rate_limiter_bytes_per_sec=200 -rate_limiter_refill_period_us=1000000 -rate_limit_bg_reads=1 -disable_auto_compactions=1 -rate_limit_user_ops=1` where each `MultiRead()` read about 2000 bytes (inspected by debugger) and the rate limiter grants 200 bytes per seconds.
- Stress test:
   - Verified `./db_stress (-test_cf_consistency=1/test_batches_snapshots=1) -use_multiget=1 -cache_size=1048576 -rate_limiter_bytes_per_sec=10241024 -rate_limit_bg_reads=1 -rate_limit_user_ops=1` work

Reviewed By: ajkr, anand1976

Differential Revision: D37135172

Pulled By: hx235

fbshipit-source-id: 73b8e8f14761e5d4b77235dfe5d41f4eea968bcd
2022-06-17 16:40:47 -07:00
..
CMakeLists.txt Stress test for RocksDB transactions (#8936) 2021-12-14 13:34:43 -08:00
batched_ops_stress.cc Add rate-limiting support to batched MultiGet() (#10159) 2022-06-17 16:40:47 -07:00
cf_consistency_stress.cc Add rate-limiting support to batched MultiGet() (#10159) 2022-06-17 16:40:47 -07:00
db_stress.cc Add (& fix) some simple source code checks (#8821) 2021-09-07 21:19:27 -07:00
db_stress_common.cc Snapshots with user-specified timestamps (#9879) 2022-06-10 16:07:03 -07:00
db_stress_common.h Remove deprecated block-based filter (#10184) 2022-06-16 15:51:33 -07:00
db_stress_compaction_filter.h Rename kRemoveWithSingleDelete to kPurge (#9951) 2022-05-05 08:16:20 -07:00
db_stress_driver.cc Snapshots with user-specified timestamps (#9879) 2022-06-10 16:07:03 -07:00
db_stress_driver.h Replace namespace name "rocksdb" with ROCKSDB_NAMESPACE (#6433) 2020-02-20 12:09:57 -08:00
db_stress_env_wrapper.h Make the Env class Customizable (#9293) 2022-01-04 16:45:49 -08:00
db_stress_gflags.cc Remove deprecated block-based filter (#10184) 2022-06-16 15:51:33 -07:00
db_stress_listener.cc Adjust public APIs to prefer 128-bit SST unique ID (#10009) 2022-05-17 18:43:48 -07:00
db_stress_listener.h Avoid usage of ReopenWritableFile in db_stress (#9649) 2022-03-04 10:30:10 -08:00
db_stress_shared_state.cc Remove ROCKSDB_SUPPORT_THREAD_LOCAL define because it's a part of C++11 (#10015) 2022-05-18 15:25:19 -07:00
db_stress_shared_state.h Remove ROCKSDB_SUPPORT_THREAD_LOCAL define because it's a part of C++11 (#10015) 2022-05-18 15:25:19 -07:00
db_stress_stat.cc Fix Statistics in db_stress (#9260) 2021-12-07 16:24:22 -08:00
db_stress_stat.h Fix Statistics in db_stress (#9260) 2021-12-07 16:24:22 -08:00
db_stress_table_properties_collector.h Fix and detect headers with missing dependencies (#8893) 2021-09-10 10:00:26 -07:00
db_stress_test_base.cc Add WriteOptions::protection_bytes_per_key (#10037) 2022-06-16 23:10:07 -07:00
db_stress_test_base.h Fix a race condition in transaction stress test (#10157) 2022-06-13 18:54:38 -07:00
db_stress_tool.cc Add WriteOptions::protection_bytes_per_key (#10037) 2022-06-16 23:10:07 -07:00
expected_state.cc Remove own ToString() (#9955) 2022-05-06 13:03:58 -07:00
expected_state.h db_stress verify with lost unsynced operations (#8966) 2021-12-15 12:54:44 -08:00
multi_ops_txns_stress.cc Fix a race condition in transaction stress test (#10157) 2022-06-13 18:54:38 -07:00
multi_ops_txns_stress.h Fix a bug of CompactionIterator/CompactionFilter using `Delete` (#9929) 2022-05-02 13:25:45 -07:00
no_batched_ops_stress.cc Add rate-limiting support to batched MultiGet() (#10159) 2022-06-17 16:40:47 -07:00