From f07eec1bf88f0a8250e9e0ecbd01946bd767e0d9 Mon Sep 17 00:00:00 2001 From: Akanksha Mahajan Date: Tue, 22 Mar 2022 17:21:35 -0700 Subject: [PATCH] Add async_io read option in db_bench (#9735) Summary: Add async_io Read option in db_bench Pull Request resolved: https://github.com/facebook/rocksdb/pull/9735 Test Plan: ./db_bench -use_existing_db=true -db=/tmp/prefix_scan_prefetch_main -benchmarks="seekrandom" -key_size=32 -value_size=512 -num=5000000 -use_direct_reads=true -seek_nexts=327680 -duration=120 -ops_between_duration_checks=1 -async_io=1 Reviewed By: riversand963 Differential Revision: D35058482 Pulled By: akankshamahajan15 fbshipit-source-id: 1522b638c79f6d85bb7408c67f6ab76dbabeeee7 --- tools/db_bench_tool.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index 85671e1f7..1aac45698 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -1124,6 +1124,10 @@ DEFINE_bool(rate_limit_auto_wal_flush, false, "false) after the user " "write operation"); +DEFINE_bool(async_io, false, + "When set true, RocksDB does asynchronous reads for internal auto " + "readahead prefetching."); + static enum ROCKSDB_NAMESPACE::CompressionType StringToCompressionType( const char* ctype) { assert(ctype); @@ -3120,6 +3124,7 @@ class Benchmark { read_options_.tailing = FLAGS_use_tailing_iterator; read_options_.readahead_size = FLAGS_readahead_size; read_options_.adaptive_readahead = FLAGS_adaptive_readahead; + read_options_.async_io = FLAGS_async_io; void (Benchmark::*method)(ThreadState*) = nullptr; void (Benchmark::*post_process_method)() = nullptr; @@ -5402,6 +5407,8 @@ class Benchmark { } options.adaptive_readahead = FLAGS_adaptive_readahead; + options.async_io = FLAGS_async_io; + Iterator* iter = db->NewIterator(options); int64_t i = 0; int64_t bytes = 0; @@ -7317,6 +7324,7 @@ class Benchmark { DB* db = SelectDB(thread); ReadOptions ro; ro.adaptive_readahead = FLAGS_adaptive_readahead; + ro.async_io = FLAGS_async_io; ro.rate_limiter_priority = FLAGS_rate_limit_user_ops ? Env::IO_USER : Env::IO_TOTAL; ro.readahead_size = FLAGS_readahead_size; @@ -7331,6 +7339,7 @@ class Benchmark { DB* db = SelectDB(thread); ReadOptions ro; ro.adaptive_readahead = FLAGS_adaptive_readahead; + ro.async_io = FLAGS_async_io; ro.rate_limiter_priority = FLAGS_rate_limit_user_ops ? Env::IO_USER : Env::IO_TOTAL; ro.readahead_size = FLAGS_readahead_size;