Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lhsoft committed Apr 11, 2024
1 parent c01a1a3 commit b1bbc4e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions include/rocksdb/utilities/cache_dump_load.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ class CacheDumpReader {
// dump or load process related control variables can be added here.
struct CacheDumpOptions {
SystemClock* clock;
// Max duration time in ms for dumper or loader
uint64_t max_duration_time_ms = 0;
// Deadline for dumper or loader in microseconds
std::chrono::microseconds deadline = std::chrono::microseconds::zero();
// Max size bytes for dumper or loader
uint64_t max_size_bytes = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion unreleased_history/new_features/cache_dumper.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Added two options `max_duration_tims_ms` and `max_size_bytes` for CacheDumper to exit early
Added two options `deadline` and `max_size_bytes` for CacheDumper to exit early
16 changes: 7 additions & 9 deletions utilities/cache_dump_load_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,11 @@ IOStatus CacheDumperImpl::DumpCacheEntriesToWriter() {
}
clock_ = options_.clock;

deadline_ = options_.deadline;

// Set the sequence number
sequence_num_ = 0;

// Set deadline
if (options_.max_duration_time_ms > 0) {
deadline_ts_ = clock_->NowMicros() + options_.max_duration_time_ms * 1000;
} else {
deadline_ts_ = std::numeric_limits<uint64_t>::max();
}

// Dump stage, first, we write the hader
IOStatus io_s = WriteHeader();
if (!io_s.ok()) {
Expand Down Expand Up @@ -132,8 +127,11 @@ CacheDumperImpl::DumpOneBlockCallBack(std::string& buf) {
}

uint64_t timestamp = clock_->NowMicros();
if (timestamp > deadline_ts_) {
return;
if (deadline_.count()) {
std::chrono::microseconds now = std::chrono::microseconds(timestamp);
if (now >= deadline_) {
return;
}
}

CacheEntryRole role = helper->role;
Expand Down
2 changes: 1 addition & 1 deletion utilities/cache_dump_load_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class CacheDumperImpl : public CacheDumper {
// filtering.
std::set<std::string> prefix_filter_;
// Deadline for dumper in microseconds.
uint64_t deadline_ts_;
std::chrono::microseconds deadline_;
uint64_t dumped_size_bytes_;
};

Expand Down

0 comments on commit b1bbc4e

Please sign in to comment.