From 78b28d80b0d9ae7b8219748412f142781fdc1e06 Mon Sep 17 00:00:00 2001 From: Levi Tamasi Date: Mon, 14 Oct 2019 17:47:56 -0700 Subject: [PATCH] Support non-TTL Puts for BlobDB in db_bench (#5921) Summary: Currently, db_bench only supports PutWithTTL operations for BlobDB but not regular Puts. The patch adds support for regular (non-TTL) Puts and also changes the default for blob_db_max_ttl_range to zero, which corresponds to no TTL. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5921 Test Plan: make check ./db_bench -benchmarks=fillrandom -statistics -stats_interval_seconds=1 -duration=90 -num=500000 -use_blob_db=1 -blob_db_file_size=1000000 -target_file_size_base=1000000 (issues Put operations with no TTL) ./db_bench -benchmarks=fillrandom -statistics -stats_interval_seconds=1 -duration=90 -num=500000 -use_blob_db=1 -blob_db_file_size=1000000 -target_file_size_base=1000000 -blob_db_max_ttl_range=86400 (issues PutWithTTL operations with random TTLs in the [0, blob_db_max_ttl_range) interval, as before) Differential Revision: D17919798 Pulled By: ltamasi fbshipit-source-id: b946c3522b836b92b4c157ffbad24f92ba2b0a16 --- tools/db_bench_tool.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index 4f2a9f8bf..cee43dff6 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -757,8 +757,9 @@ DEFINE_bool(blob_db_is_fifo, false, "Enable FIFO eviction strategy in BlobDB."); DEFINE_uint64(blob_db_max_db_size, 0, "Max size limit of the directory where blob files are stored."); -DEFINE_uint64(blob_db_max_ttl_range, 86400, - "TTL range to generate BlobDB data (in seconds)."); +DEFINE_uint64( + blob_db_max_ttl_range, 0, + "TTL range to generate BlobDB data (in seconds). 0 means no TTL."); DEFINE_uint64(blob_db_ttl_range_secs, 3600, "TTL bucket size to use when creating blob files."); @@ -4188,10 +4189,14 @@ class Benchmark { if (use_blob_db_) { #ifndef ROCKSDB_LITE Slice val = gen.Generate(value_size_); - int ttl = rand() % FLAGS_blob_db_max_ttl_range; blob_db::BlobDB* blobdb = static_cast(db_with_cfh->db); - s = blobdb->PutWithTTL(write_options_, key, val, ttl); + if (FLAGS_blob_db_max_ttl_range > 0) { + int ttl = rand() % FLAGS_blob_db_max_ttl_range; + s = blobdb->PutWithTTL(write_options_, key, val, ttl); + } else { + s = blobdb->Put(write_options_, key, val); + } #endif // ROCKSDB_LITE } else if (FLAGS_num_column_families <= 1) { batch.Put(key, gen.Generate(value_size_));