]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/db_stress_tool/db_stress_gflags.cc
import quincy beta 17.1.0
[ceph.git] / ceph / src / rocksdb / db_stress_tool / db_stress_gflags.cc
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
5 //
6 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
7 // Use of this source code is governed by a BSD-style license that can be
8 // found in the LICENSE file. See the AUTHORS file for names of contributors.
9
10 #ifdef GFLAGS
11 #include "db_stress_tool/db_stress_common.h"
12
13 static bool ValidateUint32Range(const char* flagname, uint64_t value) {
14 if (value > std::numeric_limits<uint32_t>::max()) {
15 fprintf(stderr, "Invalid value for --%s: %lu, overflow\n", flagname,
16 (unsigned long)value);
17 return false;
18 }
19 return true;
20 }
21
22 DEFINE_uint64(seed, 2341234, "Seed for PRNG");
23 static const bool FLAGS_seed_dummy __attribute__((__unused__)) =
24 RegisterFlagValidator(&FLAGS_seed, &ValidateUint32Range);
25
26 DEFINE_bool(read_only, false, "True if open DB in read-only mode during tests");
27
28 DEFINE_int64(max_key, 1 * KB * KB,
29 "Max number of key/values to place in database");
30
31 DEFINE_int32(max_key_len, 3, "Maximum length of a key in 8-byte units");
32
33 DEFINE_string(key_len_percent_dist, "",
34 "Percentages of keys of various lengths. For example, 1,30,69 "
35 "means 1% of keys are 8 bytes, 30% are 16 bytes, and 69% are "
36 "24 bytes. If not specified, it will be evenly distributed");
37
38 DEFINE_int32(key_window_scale_factor, 10,
39 "This value will be multiplied by 100 to come up with a window "
40 "size for varying the key length");
41
42 DEFINE_int32(column_families, 10, "Number of column families");
43
44 DEFINE_double(
45 hot_key_alpha, 0,
46 "Use Zipfian distribution to generate the key "
47 "distribution. If it is not specified, write path will use random "
48 "distribution to generate the keys. The parameter is [0, double_max]). "
49 "However, the larger alpha is, the more shewed will be. If alpha is "
50 "larger than 2, it is likely that only 1 key will be accessed. The "
51 "Recommended value is [0.8-1.5]. The distribution is also related to "
52 "max_key and total iterations of generating the hot key. ");
53
54 DEFINE_string(
55 options_file, "",
56 "The path to a RocksDB options file. If specified, then db_stress will "
57 "run with the RocksDB options in the default column family of the "
58 "specified options file. Note that, when an options file is provided, "
59 "db_stress will ignore the flag values for all options that may be passed "
60 "via options file.");
61
62 DEFINE_int64(
63 active_width, 0,
64 "Number of keys in active span of the key-range at any given time. The "
65 "span begins with its left endpoint at key 0, gradually moves rightwards, "
66 "and ends with its right endpoint at max_key. If set to 0, active_width "
67 "will be sanitized to be equal to max_key.");
68
69 // TODO(noetzli) Add support for single deletes
70 DEFINE_bool(test_batches_snapshots, false,
71 "If set, the test uses MultiGet(), MultiPut() and MultiDelete()"
72 " which read/write/delete multiple keys in a batch. In this mode,"
73 " we do not verify db content by comparing the content with the "
74 "pre-allocated array. Instead, we do partial verification inside"
75 " MultiGet() by checking various values in a batch. Benefit of"
76 " this mode:\n"
77 "\t(a) No need to acquire mutexes during writes (less cache "
78 "flushes in multi-core leading to speed up)\n"
79 "\t(b) No long validation at the end (more speed up)\n"
80 "\t(c) Test snapshot and atomicity of batch writes");
81
82 DEFINE_bool(atomic_flush, false,
83 "If set, enables atomic flush in the options.\n");
84
85 DEFINE_bool(test_cf_consistency, false,
86 "If set, runs the stress test dedicated to verifying writes to "
87 "multiple column families are consistent. Setting this implies "
88 "`atomic_flush=true` is set true if `disable_wal=false`.\n");
89
90 DEFINE_int32(threads, 32, "Number of concurrent threads to run.");
91
92 DEFINE_int32(ttl, -1,
93 "Opens the db with this ttl value if this is not -1. "
94 "Carefully specify a large value such that verifications on "
95 "deleted values don't fail");
96
97 DEFINE_int32(value_size_mult, 8,
98 "Size of value will be this number times rand_int(1,3) bytes");
99
100 DEFINE_int32(compaction_readahead_size, 0, "Compaction readahead size");
101
102 DEFINE_bool(enable_pipelined_write, false, "Pipeline WAL/memtable writes");
103
104 DEFINE_bool(verify_before_write, false, "Verify before write");
105
106 DEFINE_bool(histogram, false, "Print histogram of operation timings");
107
108 DEFINE_bool(destroy_db_initially, true,
109 "Destroys the database dir before start if this is true");
110
111 DEFINE_bool(verbose, false, "Verbose");
112
113 DEFINE_bool(progress_reports, true,
114 "If true, db_stress will report number of finished operations");
115
116 DEFINE_uint64(db_write_buffer_size,
117 ROCKSDB_NAMESPACE::Options().db_write_buffer_size,
118 "Number of bytes to buffer in all memtables before compacting");
119
120 DEFINE_int32(
121 write_buffer_size,
122 static_cast<int32_t>(ROCKSDB_NAMESPACE::Options().write_buffer_size),
123 "Number of bytes to buffer in memtable before compacting");
124
125 DEFINE_int32(max_write_buffer_number,
126 ROCKSDB_NAMESPACE::Options().max_write_buffer_number,
127 "The number of in-memory memtables. "
128 "Each memtable is of size FLAGS_write_buffer_size.");
129
130 DEFINE_int32(min_write_buffer_number_to_merge,
131 ROCKSDB_NAMESPACE::Options().min_write_buffer_number_to_merge,
132 "The minimum number of write buffers that will be merged together "
133 "before writing to storage. This is cheap because it is an "
134 "in-memory merge. If this feature is not enabled, then all these "
135 "write buffers are flushed to L0 as separate files and this "
136 "increases read amplification because a get request has to check "
137 "in all of these files. Also, an in-memory merge may result in "
138 "writing less data to storage if there are duplicate records in"
139 " each of these individual write buffers.");
140
141 DEFINE_int32(max_write_buffer_number_to_maintain,
142 ROCKSDB_NAMESPACE::Options().max_write_buffer_number_to_maintain,
143 "The total maximum number of write buffers to maintain in memory "
144 "including copies of buffers that have already been flushed. "
145 "Unlike max_write_buffer_number, this parameter does not affect "
146 "flushing. This controls the minimum amount of write history "
147 "that will be available in memory for conflict checking when "
148 "Transactions are used. If this value is too low, some "
149 "transactions may fail at commit time due to not being able to "
150 "determine whether there were any write conflicts. Setting this "
151 "value to 0 will cause write buffers to be freed immediately "
152 "after they are flushed. If this value is set to -1, "
153 "'max_write_buffer_number' will be used.");
154
155 DEFINE_int64(max_write_buffer_size_to_maintain,
156 ROCKSDB_NAMESPACE::Options().max_write_buffer_size_to_maintain,
157 "The total maximum size of write buffers to maintain in memory "
158 "including copies of buffers that have already been flushed. "
159 "Unlike max_write_buffer_number, this parameter does not affect "
160 "flushing. This controls the minimum amount of write history "
161 "that will be available in memory for conflict checking when "
162 "Transactions are used. If this value is too low, some "
163 "transactions may fail at commit time due to not being able to "
164 "determine whether there were any write conflicts. Setting this "
165 "value to 0 will cause write buffers to be freed immediately "
166 "after they are flushed. If this value is set to -1, "
167 "'max_write_buffer_number' will be used.");
168
169 DEFINE_double(memtable_prefix_bloom_size_ratio,
170 ROCKSDB_NAMESPACE::Options().memtable_prefix_bloom_size_ratio,
171 "creates prefix blooms for memtables, each with size "
172 "`write_buffer_size * memtable_prefix_bloom_size_ratio`.");
173
174 DEFINE_bool(memtable_whole_key_filtering,
175 ROCKSDB_NAMESPACE::Options().memtable_whole_key_filtering,
176 "Enable whole key filtering in memtables.");
177
178 DEFINE_int32(open_files, ROCKSDB_NAMESPACE::Options().max_open_files,
179 "Maximum number of files to keep open at the same time "
180 "(use default if == 0)");
181
182 DEFINE_int64(compressed_cache_size, -1,
183 "Number of bytes to use as a cache of compressed data."
184 " Negative means use default settings.");
185
186 DEFINE_int32(compaction_style, ROCKSDB_NAMESPACE::Options().compaction_style,
187 "");
188
189 DEFINE_int32(num_levels, ROCKSDB_NAMESPACE::Options().num_levels,
190 "Number of levels in the DB");
191
192 DEFINE_int32(level0_file_num_compaction_trigger,
193 ROCKSDB_NAMESPACE::Options().level0_file_num_compaction_trigger,
194 "Level0 compaction start trigger");
195
196 DEFINE_int32(level0_slowdown_writes_trigger,
197 ROCKSDB_NAMESPACE::Options().level0_slowdown_writes_trigger,
198 "Number of files in level-0 that will slow down writes");
199
200 DEFINE_int32(level0_stop_writes_trigger,
201 ROCKSDB_NAMESPACE::Options().level0_stop_writes_trigger,
202 "Number of files in level-0 that will trigger put stop.");
203
204 DEFINE_int32(block_size,
205 static_cast<int32_t>(
206 ROCKSDB_NAMESPACE::BlockBasedTableOptions().block_size),
207 "Number of bytes in a block.");
208
209 DEFINE_int32(format_version,
210 static_cast<int32_t>(
211 ROCKSDB_NAMESPACE::BlockBasedTableOptions().format_version),
212 "Format version of SST files.");
213
214 DEFINE_int32(
215 index_block_restart_interval,
216 ROCKSDB_NAMESPACE::BlockBasedTableOptions().index_block_restart_interval,
217 "Number of keys between restart points "
218 "for delta encoding of keys in index block.");
219
220 DEFINE_int32(max_background_compactions,
221 ROCKSDB_NAMESPACE::Options().max_background_compactions,
222 "The maximum number of concurrent background compactions "
223 "that can occur in parallel.");
224
225 DEFINE_int32(num_bottom_pri_threads, 0,
226 "The number of threads in the bottom-priority thread pool (used "
227 "by universal compaction only).");
228
229 DEFINE_int32(compaction_thread_pool_adjust_interval, 0,
230 "The interval (in milliseconds) to adjust compaction thread pool "
231 "size. Don't change it periodically if the value is 0.");
232
233 DEFINE_int32(compaction_thread_pool_variations, 2,
234 "Range of background thread pool size variations when adjusted "
235 "periodically.");
236
237 DEFINE_int32(max_background_flushes,
238 ROCKSDB_NAMESPACE::Options().max_background_flushes,
239 "The maximum number of concurrent background flushes "
240 "that can occur in parallel.");
241
242 DEFINE_int32(universal_size_ratio, 0,
243 "The ratio of file sizes that trigger"
244 " compaction in universal style");
245
246 DEFINE_int32(universal_min_merge_width, 0,
247 "The minimum number of files to "
248 "compact in universal style compaction");
249
250 DEFINE_int32(universal_max_merge_width, 0,
251 "The max number of files to compact"
252 " in universal style compaction");
253
254 DEFINE_int32(universal_max_size_amplification_percent, 0,
255 "The max size amplification for universal style compaction");
256
257 DEFINE_int32(clear_column_family_one_in, 1000000,
258 "With a chance of 1/N, delete a column family and then recreate "
259 "it again. If N == 0, never drop/create column families. "
260 "When test_batches_snapshots is true, this flag has no effect");
261
262 DEFINE_int32(get_live_files_one_in, 1000000,
263 "With a chance of 1/N, call GetLiveFiles to verify if it returns "
264 "correctly. If N == 0, do not call the interface.");
265
266 DEFINE_int32(
267 get_sorted_wal_files_one_in, 1000000,
268 "With a chance of 1/N, call GetSortedWalFiles to verify if it returns "
269 "correctly. (Note that this API may legitimately return an error.) If N == "
270 "0, do not call the interface.");
271
272 DEFINE_int32(
273 get_current_wal_file_one_in, 1000000,
274 "With a chance of 1/N, call GetCurrentWalFile to verify if it returns "
275 "correctly. (Note that this API may legitimately return an error.) If N == "
276 "0, do not call the interface.");
277
278 DEFINE_int32(set_options_one_in, 0,
279 "With a chance of 1/N, change some random options");
280
281 DEFINE_int32(set_in_place_one_in, 0,
282 "With a chance of 1/N, toggle in place support option");
283
284 DEFINE_int64(cache_size, 2LL * KB * KB * KB,
285 "Number of bytes to use as a cache of uncompressed data.");
286
287 DEFINE_bool(cache_index_and_filter_blocks, false,
288 "True if indexes/filters should be cached in block cache.");
289
290 DEFINE_int32(
291 top_level_index_pinning,
292 static_cast<int32_t>(ROCKSDB_NAMESPACE::PinningTier::kFallback),
293 "Type of pinning for top-level indexes into metadata partitions (see "
294 "`enum PinningTier` in table.h)");
295
296 DEFINE_int32(
297 partition_pinning,
298 static_cast<int32_t>(ROCKSDB_NAMESPACE::PinningTier::kFallback),
299 "Type of pinning for metadata partitions (see `enum PinningTier` in "
300 "table.h)");
301
302 DEFINE_int32(
303 unpartitioned_pinning,
304 static_cast<int32_t>(ROCKSDB_NAMESPACE::PinningTier::kFallback),
305 "Type of pinning for unpartitioned metadata blocks (see `enum PinningTier` "
306 "in table.h)");
307
308 DEFINE_bool(use_clock_cache, false,
309 "Replace default LRU block cache with clock cache.");
310
311 DEFINE_uint64(subcompactions, 1,
312 "Maximum number of subcompactions to divide L0-L1 compactions "
313 "into.");
314
315 DEFINE_uint64(periodic_compaction_seconds, 1000,
316 "Files older than this value will be picked up for compaction.");
317
318 DEFINE_uint64(compaction_ttl, 1000,
319 "Files older than TTL will be compacted to the next level.");
320
321 DEFINE_bool(allow_concurrent_memtable_write, false,
322 "Allow multi-writers to update mem tables in parallel.");
323
324 DEFINE_bool(enable_write_thread_adaptive_yield, true,
325 "Use a yielding spin loop for brief writer thread waits.");
326
327 #ifndef ROCKSDB_LITE
328 // BlobDB Options
329 DEFINE_bool(use_blob_db, false, "Use BlobDB.");
330
331 DEFINE_uint64(blob_db_min_blob_size,
332 ROCKSDB_NAMESPACE::blob_db::BlobDBOptions().min_blob_size,
333 "Smallest blob to store in a file. Blobs smaller than this "
334 "will be inlined with the key in the LSM tree.");
335
336 DEFINE_uint64(blob_db_bytes_per_sync,
337 ROCKSDB_NAMESPACE::blob_db::BlobDBOptions().bytes_per_sync,
338 "Sync blob files once per every N bytes written.");
339
340 DEFINE_uint64(blob_db_file_size,
341 ROCKSDB_NAMESPACE::blob_db::BlobDBOptions().blob_file_size,
342 "Target size of each blob file.");
343
344 DEFINE_bool(
345 blob_db_enable_gc,
346 ROCKSDB_NAMESPACE::blob_db::BlobDBOptions().enable_garbage_collection,
347 "Enable BlobDB garbage collection.");
348
349 DEFINE_double(
350 blob_db_gc_cutoff,
351 ROCKSDB_NAMESPACE::blob_db::BlobDBOptions().garbage_collection_cutoff,
352 "Cutoff ratio for BlobDB garbage collection.");
353 #endif // !ROCKSDB_LITE
354
355 static const bool FLAGS_subcompactions_dummy __attribute__((__unused__)) =
356 RegisterFlagValidator(&FLAGS_subcompactions, &ValidateUint32Range);
357
358 static bool ValidateInt32Positive(const char* flagname, int32_t value) {
359 if (value < 0) {
360 fprintf(stderr, "Invalid value for --%s: %d, must be >=0\n", flagname,
361 value);
362 return false;
363 }
364 return true;
365 }
366 DEFINE_int32(reopen, 10, "Number of times database reopens");
367 static const bool FLAGS_reopen_dummy __attribute__((__unused__)) =
368 RegisterFlagValidator(&FLAGS_reopen, &ValidateInt32Positive);
369
370 DEFINE_double(bloom_bits, 10,
371 "Bloom filter bits per key. "
372 "Negative means use default settings.");
373
374 DEFINE_bool(use_block_based_filter, false,
375 "use block based filter"
376 "instead of full filter for block based table");
377
378 DEFINE_bool(use_ribbon_filter, false,
379 "Use Ribbon filter instead of Bloom filter");
380
381 DEFINE_bool(partition_filters, false,
382 "use partitioned filters "
383 "for block-based table");
384
385 DEFINE_bool(
386 optimize_filters_for_memory,
387 ROCKSDB_NAMESPACE::BlockBasedTableOptions().optimize_filters_for_memory,
388 "Minimize memory footprint of filters");
389
390 DEFINE_int32(
391 index_type,
392 static_cast<int32_t>(
393 ROCKSDB_NAMESPACE::BlockBasedTableOptions::kBinarySearch),
394 "Type of block-based table index (see `enum IndexType` in table.h)");
395
396 DEFINE_string(db, "", "Use the db with the following name.");
397
398 DEFINE_string(secondaries_base, "",
399 "Use this path as the base path for secondary instances.");
400
401 DEFINE_bool(test_secondary, false, "Test secondary instance.");
402
403 DEFINE_string(
404 expected_values_path, "",
405 "File where the array of expected uint32_t values will be stored. If "
406 "provided and non-empty, the DB state will be verified against these "
407 "values after recovery. --max_key and --column_family must be kept the "
408 "same across invocations of this program that use the same "
409 "--expected_values_path.");
410
411 DEFINE_bool(verify_checksum, false,
412 "Verify checksum for every block read from storage");
413
414 DEFINE_bool(mmap_read, ROCKSDB_NAMESPACE::Options().allow_mmap_reads,
415 "Allow reads to occur via mmap-ing files");
416
417 DEFINE_bool(mmap_write, ROCKSDB_NAMESPACE::Options().allow_mmap_writes,
418 "Allow writes to occur via mmap-ing files");
419
420 DEFINE_bool(use_direct_reads, ROCKSDB_NAMESPACE::Options().use_direct_reads,
421 "Use O_DIRECT for reading data");
422
423 DEFINE_bool(use_direct_io_for_flush_and_compaction,
424 ROCKSDB_NAMESPACE::Options().use_direct_io_for_flush_and_compaction,
425 "Use O_DIRECT for writing data");
426
427 DEFINE_bool(mock_direct_io, false,
428 "Mock direct IO by not using O_DIRECT for direct IO read");
429
430 DEFINE_bool(statistics, false, "Create database statistics");
431
432 DEFINE_bool(sync, false, "Sync all writes to disk");
433
434 DEFINE_bool(use_fsync, false, "If true, issue fsync instead of fdatasync");
435
436 DEFINE_int32(kill_random_test, 0,
437 "If non-zero, kill at various points in source code with "
438 "probability 1/this");
439 static const bool FLAGS_kill_random_test_dummy __attribute__((__unused__)) =
440 RegisterFlagValidator(&FLAGS_kill_random_test, &ValidateInt32Positive);
441 extern int rocksdb_kill_odds;
442
443 DEFINE_string(kill_exclude_prefixes, "",
444 "If non-empty, kill points with prefix in the list given will be"
445 " skipped. Items are comma-separated.");
446 extern std::vector<std::string> rocksdb_kill_exclude_prefixes;
447
448 DEFINE_bool(disable_wal, false, "If true, do not write WAL for write.");
449
450 DEFINE_uint64(recycle_log_file_num,
451 ROCKSDB_NAMESPACE::Options().recycle_log_file_num,
452 "Number of old WAL files to keep around for later recycling");
453
454 DEFINE_int64(target_file_size_base,
455 ROCKSDB_NAMESPACE::Options().target_file_size_base,
456 "Target level-1 file size for compaction");
457
458 DEFINE_int32(target_file_size_multiplier, 1,
459 "A multiplier to compute target level-N file size (N >= 2)");
460
461 DEFINE_uint64(max_bytes_for_level_base,
462 ROCKSDB_NAMESPACE::Options().max_bytes_for_level_base,
463 "Max bytes for level-1");
464
465 DEFINE_double(max_bytes_for_level_multiplier, 2,
466 "A multiplier to compute max bytes for level-N (N >= 2)");
467
468 DEFINE_int32(range_deletion_width, 10,
469 "The width of the range deletion intervals.");
470
471 DEFINE_uint64(rate_limiter_bytes_per_sec, 0, "Set options.rate_limiter value.");
472
473 DEFINE_bool(rate_limit_bg_reads, false,
474 "Use options.rate_limiter on compaction reads");
475
476 DEFINE_uint64(sst_file_manager_bytes_per_sec, 0,
477 "Set `Options::sst_file_manager` to delete at this rate. By "
478 "default the deletion rate is unbounded.");
479
480 DEFINE_uint64(sst_file_manager_bytes_per_truncate, 0,
481 "Set `Options::sst_file_manager` to delete in chunks of this "
482 "many bytes. By default whole files will be deleted.");
483
484 DEFINE_bool(use_txn, false,
485 "Use TransactionDB. Currently the default write policy is "
486 "TxnDBWritePolicy::WRITE_PREPARED");
487
488 DEFINE_uint64(txn_write_policy, 0,
489 "The transaction write policy. Default is "
490 "TxnDBWritePolicy::WRITE_COMMITTED. Note that this should not be "
491 "changed accross crashes.");
492
493 DEFINE_bool(unordered_write, false,
494 "Turn on the unordered_write feature. This options is currently "
495 "tested only in combination with use_txn=true and "
496 "txn_write_policy=TxnDBWritePolicy::WRITE_PREPARED.");
497
498 DEFINE_int32(backup_one_in, 0,
499 "If non-zero, then CreateNewBackup() will be called once for "
500 "every N operations on average. 0 indicates CreateNewBackup() "
501 "is disabled.");
502
503 DEFINE_uint64(backup_max_size, 100 * 1024 * 1024,
504 "If non-zero, skip checking backup/restore when DB size in "
505 "bytes exceeds this setting.");
506
507 DEFINE_int32(checkpoint_one_in, 0,
508 "If non-zero, then CreateCheckpoint() will be called once for "
509 "every N operations on average. 0 indicates CreateCheckpoint() "
510 "is disabled.");
511
512 DEFINE_int32(ingest_external_file_one_in, 0,
513 "If non-zero, then IngestExternalFile() will be called once for "
514 "every N operations on average. 0 indicates IngestExternalFile() "
515 "is disabled.");
516
517 DEFINE_int32(ingest_external_file_width, 1000,
518 "The width of the ingested external files.");
519
520 DEFINE_int32(compact_files_one_in, 0,
521 "If non-zero, then CompactFiles() will be called once for every N "
522 "operations on average. 0 indicates CompactFiles() is disabled.");
523
524 DEFINE_int32(compact_range_one_in, 0,
525 "If non-zero, then CompactRange() will be called once for every N "
526 "operations on average. 0 indicates CompactRange() is disabled.");
527
528 DEFINE_int32(mark_for_compaction_one_file_in, 0,
529 "A `TablePropertiesCollectorFactory` will be registered, which "
530 "creates a `TablePropertiesCollector` with `NeedCompact()` "
531 "returning true once for every N files on average. 0 or negative "
532 "mean `NeedCompact()` always returns false.");
533
534 DEFINE_int32(flush_one_in, 0,
535 "If non-zero, then Flush() will be called once for every N ops "
536 "on average. 0 indicates calls to Flush() are disabled.");
537
538 DEFINE_int32(pause_background_one_in, 0,
539 "If non-zero, then PauseBackgroundWork()+Continue will be called "
540 "once for every N ops on average. 0 disables.");
541
542 DEFINE_int32(compact_range_width, 10000,
543 "The width of the ranges passed to CompactRange().");
544
545 DEFINE_int32(acquire_snapshot_one_in, 0,
546 "If non-zero, then acquires a snapshot once every N operations on "
547 "average.");
548
549 DEFINE_bool(compare_full_db_state_snapshot, false,
550 "If set we compare state of entire db (in one of the threads) with"
551 "each snapshot.");
552
553 DEFINE_uint64(snapshot_hold_ops, 0,
554 "If non-zero, then releases snapshots N operations after they're "
555 "acquired.");
556
557 DEFINE_bool(long_running_snapshots, false,
558 "If set, hold on some some snapshots for much longer time.");
559
560 DEFINE_bool(use_multiget, false,
561 "If set, use the batched MultiGet API for reads");
562
563 static bool ValidateInt32Percent(const char* flagname, int32_t value) {
564 if (value < 0 || value > 100) {
565 fprintf(stderr, "Invalid value for --%s: %d, 0<= pct <=100 \n", flagname,
566 value);
567 return false;
568 }
569 return true;
570 }
571
572 DEFINE_int32(readpercent, 10,
573 "Ratio of reads to total workload (expressed as a percentage)");
574 static const bool FLAGS_readpercent_dummy __attribute__((__unused__)) =
575 RegisterFlagValidator(&FLAGS_readpercent, &ValidateInt32Percent);
576
577 DEFINE_int32(prefixpercent, 20,
578 "Ratio of prefix iterators to total workload (expressed as a"
579 " percentage)");
580 static const bool FLAGS_prefixpercent_dummy __attribute__((__unused__)) =
581 RegisterFlagValidator(&FLAGS_prefixpercent, &ValidateInt32Percent);
582
583 DEFINE_int32(writepercent, 45,
584 "Ratio of writes to total workload (expressed as a percentage)");
585 static const bool FLAGS_writepercent_dummy __attribute__((__unused__)) =
586 RegisterFlagValidator(&FLAGS_writepercent, &ValidateInt32Percent);
587
588 DEFINE_int32(delpercent, 15,
589 "Ratio of deletes to total workload (expressed as a percentage)");
590 static const bool FLAGS_delpercent_dummy __attribute__((__unused__)) =
591 RegisterFlagValidator(&FLAGS_delpercent, &ValidateInt32Percent);
592
593 DEFINE_int32(delrangepercent, 0,
594 "Ratio of range deletions to total workload (expressed as a "
595 "percentage). Cannot be used with test_batches_snapshots");
596 static const bool FLAGS_delrangepercent_dummy __attribute__((__unused__)) =
597 RegisterFlagValidator(&FLAGS_delrangepercent, &ValidateInt32Percent);
598
599 DEFINE_int32(nooverwritepercent, 60,
600 "Ratio of keys without overwrite to total workload (expressed as "
601 " a percentage)");
602 static const bool FLAGS_nooverwritepercent_dummy __attribute__((__unused__)) =
603 RegisterFlagValidator(&FLAGS_nooverwritepercent, &ValidateInt32Percent);
604
605 DEFINE_int32(iterpercent, 10,
606 "Ratio of iterations to total workload"
607 " (expressed as a percentage)");
608 static const bool FLAGS_iterpercent_dummy __attribute__((__unused__)) =
609 RegisterFlagValidator(&FLAGS_iterpercent, &ValidateInt32Percent);
610
611 DEFINE_uint64(num_iterations, 10, "Number of iterations per MultiIterate run");
612 static const bool FLAGS_num_iterations_dummy __attribute__((__unused__)) =
613 RegisterFlagValidator(&FLAGS_num_iterations, &ValidateUint32Range);
614
615 DEFINE_string(compression_type, "snappy",
616 "Algorithm to use to compress the database");
617
618 DEFINE_int32(compression_max_dict_bytes, 0,
619 "Maximum size of dictionary used to prime the compression "
620 "library.");
621
622 DEFINE_int32(compression_zstd_max_train_bytes, 0,
623 "Maximum size of training data passed to zstd's dictionary "
624 "trainer.");
625
626 DEFINE_int32(compression_parallel_threads, 1,
627 "Number of threads for parallel compression.");
628
629 DEFINE_string(bottommost_compression_type, "disable",
630 "Algorithm to use to compress bottommost level of the database. "
631 "\"disable\" means disabling the feature");
632
633 DEFINE_string(checksum_type, "kCRC32c", "Algorithm to use to checksum blocks");
634
635 DEFINE_string(hdfs, "",
636 "Name of hdfs environment. Mutually exclusive with"
637 " --env_uri and --fs_uri.");
638
639 DEFINE_string(
640 env_uri, "",
641 "URI for env lookup. Mutually exclusive with --hdfs and --fs_uri");
642
643 DEFINE_string(fs_uri, "",
644 "URI for registry Filesystem lookup. Mutually exclusive"
645 " with --hdfs and --env_uri."
646 " Creates a default environment with the specified filesystem.");
647
648 DEFINE_uint64(ops_per_thread, 1200000, "Number of operations per thread.");
649 static const bool FLAGS_ops_per_thread_dummy __attribute__((__unused__)) =
650 RegisterFlagValidator(&FLAGS_ops_per_thread, &ValidateUint32Range);
651
652 DEFINE_uint64(log2_keys_per_lock, 2, "Log2 of number of keys per lock");
653 static const bool FLAGS_log2_keys_per_lock_dummy __attribute__((__unused__)) =
654 RegisterFlagValidator(&FLAGS_log2_keys_per_lock, &ValidateUint32Range);
655
656 DEFINE_uint64(max_manifest_file_size, 16384, "Maximum size of a MANIFEST file");
657
658 DEFINE_bool(in_place_update, false, "On true, does inplace update in memtable");
659
660 DEFINE_int32(secondary_catch_up_one_in, 0,
661 "If non-zero, the secondaries attemp to catch up with the primary "
662 "once for every N operations on average. 0 indicates the "
663 "secondaries do not try to catch up after open.");
664
665 DEFINE_string(memtablerep, "skip_list", "");
666
667 inline static bool ValidatePrefixSize(const char* flagname, int32_t value) {
668 if (value < -1 || value > 8) {
669 fprintf(stderr, "Invalid value for --%s: %d. -1 <= PrefixSize <= 8\n",
670 flagname, value);
671 return false;
672 }
673 return true;
674 }
675 DEFINE_int32(prefix_size, 7,
676 "Control the prefix size for HashSkipListRep. "
677 "-1 is disabled.");
678 static const bool FLAGS_prefix_size_dummy __attribute__((__unused__)) =
679 RegisterFlagValidator(&FLAGS_prefix_size, &ValidatePrefixSize);
680
681 DEFINE_bool(use_merge, false,
682 "On true, replaces all writes with a Merge "
683 "that behaves like a Put");
684
685 DEFINE_bool(use_full_merge_v1, false,
686 "On true, use a merge operator that implement the deprecated "
687 "version of FullMerge");
688
689 DEFINE_int32(sync_wal_one_in, 0,
690 "If non-zero, then SyncWAL() will be called once for every N ops "
691 "on average. 0 indicates that calls to SyncWAL() are disabled.");
692
693 DEFINE_bool(avoid_unnecessary_blocking_io,
694 ROCKSDB_NAMESPACE::Options().avoid_unnecessary_blocking_io,
695 "If true, some expensive cleaning up operations will be moved from "
696 "user reads to high-pri background threads.");
697
698 DEFINE_bool(write_dbid_to_manifest,
699 ROCKSDB_NAMESPACE::Options().write_dbid_to_manifest,
700 "Write DB_ID to manifest");
701
702 DEFINE_bool(avoid_flush_during_recovery,
703 ROCKSDB_NAMESPACE::Options().avoid_flush_during_recovery,
704 "Avoid flush during recovery");
705
706 DEFINE_uint64(max_write_batch_group_size_bytes,
707 ROCKSDB_NAMESPACE::Options().max_write_batch_group_size_bytes,
708 "Max write batch group size");
709
710 DEFINE_bool(level_compaction_dynamic_level_bytes,
711 ROCKSDB_NAMESPACE::Options().level_compaction_dynamic_level_bytes,
712 "Use dynamic level");
713
714 DEFINE_int32(verify_checksum_one_in, 0,
715 "If non-zero, then DB::VerifyChecksum() will be called to do"
716 " checksum verification of all the files in the database once for"
717 " every N ops on average. 0 indicates that calls to"
718 " VerifyChecksum() are disabled.");
719 DEFINE_int32(verify_db_one_in, 0,
720 "If non-zero, call VerifyDb() once for every N ops. 0 indicates "
721 "that VerifyDb() will not be called in OperateDb(). Note that "
722 "enabling this can slow down tests.");
723
724 DEFINE_int32(continuous_verification_interval, 1000,
725 "While test is running, verify db every N milliseconds. 0 "
726 "disables continuous verification.");
727
728 DEFINE_int32(approximate_size_one_in, 64,
729 "If non-zero, DB::GetApproximateSizes() will be called against"
730 " random key ranges.");
731
732 DEFINE_int32(read_fault_one_in, 1000,
733 "On non-zero, enables fault injection on read");
734
735 DEFINE_int32(get_property_one_in, 1000,
736 "If non-zero, then DB::GetProperty() will be called to get various"
737 " properties for every N ops on average. 0 indicates that"
738 " GetProperty() will be not be called.");
739
740 DEFINE_bool(sync_fault_injection, false,
741 "If true, FaultInjectionTestFS will be used for write operations, "
742 " and unsynced data in DB will lost after crash.");
743
744 DEFINE_bool(best_efforts_recovery, false,
745 "If true, use best efforts recovery.");
746 DEFINE_bool(skip_verifydb, false, "If true, skip VerifyDb() calls.");
747
748 DEFINE_bool(enable_compaction_filter, false,
749 "If true, configures a compaction filter that returns a kRemove "
750 "decision for deleted keys.");
751
752 DEFINE_bool(paranoid_file_checks, true,
753 "After writing every SST file, reopen it and read all the keys "
754 "and validate checksums");
755
756 DEFINE_string(file_checksum_impl, "none",
757 "Name of an implementation for file_checksum_gen_factory, or "
758 "\"none\" for null.");
759
760 #endif // GFLAGS