diff --git a/HISTORY.md b/HISTORY.md index e20b00a1a..8b0bd1b70 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,4 +1,8 @@ # Rocksdb Change Log +## Unreleased +### Public API change +* Added values to `TraceFilterType`: `kTraceFilterIteratorSeek`, `kTraceFilterIteratorSeekForPrev`, and `kTraceFilterMultiGet`. They can be set in `TraceOptions` to filter out the operation types after which they are named. + ## 6.28.0 (2021-12-17) ### New Features * Introduced 'CommitWithTimestamp' as a new tag. Currently, there is no API for user to trigger a write with this tag to the WAL. This is part of the efforts to support write-commited transactions with user-defined timestamps. diff --git a/db_stress_tool/expected_state.cc b/db_stress_tool/expected_state.cc index 86bfdb95e..6c2c51abc 100644 --- a/db_stress_tool/expected_state.cc +++ b/db_stress_tool/expected_state.cc @@ -298,6 +298,9 @@ Status FileExpectedStateManager::SaveAtAndAfter(DB* db) { if (s.ok()) { TraceOptions trace_opts; trace_opts.filter |= kTraceFilterGet; + trace_opts.filter |= kTraceFilterMultiGet; + trace_opts.filter |= kTraceFilterIteratorSeek; + trace_opts.filter |= kTraceFilterIteratorSeekForPrev; s = db->StartTrace(trace_opts, std::move(trace_writer)); } diff --git a/include/rocksdb/options.h b/include/rocksdb/options.h index f593e1243..2f18b132e 100644 --- a/include/rocksdb/options.h +++ b/include/rocksdb/options.h @@ -1851,7 +1851,13 @@ enum TraceFilterType : uint64_t { // Do not trace the get operations kTraceFilterGet = 0x1 << 0, // Do not trace the write operations - kTraceFilterWrite = 0x1 << 1 + kTraceFilterWrite = 0x1 << 1, + // Do not trace the `Iterator::Seek()` operations + kTraceFilterIteratorSeek = 0x1 << 2, + // Do not trace the `Iterator::SeekForPrev()` operations + kTraceFilterIteratorSeekForPrev = 0x1 << 3, + // Do not trace the `MultiGet()` operations + kTraceFilterMultiGet = 0x1 << 4, }; // TraceOptions is used for StartTrace diff --git a/trace_replay/trace_replay.cc b/trace_replay/trace_replay.cc index 89bea7870..37b95852b 100644 --- a/trace_replay/trace_replay.cc +++ b/trace_replay/trace_replay.cc @@ -532,11 +532,46 @@ bool Tracer::ShouldSkipTrace(const TraceType& trace_type) { if (IsTraceFileOverMax()) { return true; } - if ((trace_options_.filter & kTraceFilterGet && trace_type == kTraceGet) || - (trace_options_.filter & kTraceFilterWrite && - trace_type == kTraceWrite)) { + + TraceFilterType filter_mask = kTraceFilterNone; + switch (trace_type) { + case kTraceNone: + case kTraceBegin: + case kTraceEnd: + filter_mask = kTraceFilterNone; + break; + case kTraceWrite: + filter_mask = kTraceFilterWrite; + break; + case kTraceGet: + filter_mask = kTraceFilterGet; + break; + case kTraceIteratorSeek: + filter_mask = kTraceFilterIteratorSeek; + break; + case kTraceIteratorSeekForPrev: + filter_mask = kTraceFilterIteratorSeekForPrev; + break; + case kBlockTraceIndexBlock: + case kBlockTraceFilterBlock: + case kBlockTraceDataBlock: + case kBlockTraceUncompressionDictBlock: + case kBlockTraceRangeDeletionBlock: + case kIOTracer: + filter_mask = kTraceFilterNone; + break; + case kTraceMultiGet: + filter_mask = kTraceFilterMultiGet; + break; + case kTraceMax: + assert(false); + filter_mask = kTraceFilterNone; + break; + } + if (filter_mask != kTraceFilterNone && trace_options_.filter & filter_mask) { return true; } + ++trace_request_count_; if (trace_request_count_ < trace_options_.sampling_frequency) { return true;