mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-30 22:41:48 +00:00
2dab137182
Summary: - The struct previously named `OffpeakTimeInfo` has been renamed to `OffpeakTimeOption` to indicate that it's a user-configurable option. Additionally, a new struct, `OffpeakTimeInfo`, has been introduced, which includes two fields: `is_now_offpeak` and `seconds_till_next_offpeak_start`. This change prevents the need to parse the `daily_offpeak_time_utc` string twice. - It's worth noting that we may consider adding more fields to the `OffpeakTimeInfo` struct, such as `elapsed_seconds` and `total_seconds`, as needed for further optimization. - Within `VersionStorageInfo::ComputeFilesMarkedForPeriodicCompaction()`, we've adjusted the `allowed_time_limit` to include files that are expected to expire by the next offpeak start. - We might explore further optimizations, such as evenly distributing files to mark during offpeak hours, if the initial approach results in marking too many files simultaneously during the first scoring in offpeak hours. The primary objective of this PR is to prevent periodic compactions during non-offpeak hours when offpeak hours are configured. We'll start with this straightforward solution and assess whether it suffices for now. Pull Request resolved: https://github.com/facebook/rocksdb/pull/12031 Test Plan: Unit Tests added - `DBCompactionTest::LevelPeriodicCompactionOffpeak` for Leveled - `DBTestUniversalCompaction2::PeriodicCompaction` for Universal Reviewed By: cbi42 Differential Revision: D50900292 Pulled By: jaykorean fbshipit-source-id: 267e7d3332d45a5d9881796786c8650fa0a3b43d
37 lines
1 KiB
C++
37 lines
1 KiB
C++
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include "rocksdb/rocksdb_namespace.h"
|
|
|
|
namespace ROCKSDB_NAMESPACE {
|
|
class SystemClock;
|
|
|
|
struct OffpeakTimeInfo {
|
|
bool is_now_offpeak = false;
|
|
int seconds_till_next_offpeak_start = 0;
|
|
};
|
|
|
|
struct OffpeakTimeOption {
|
|
static constexpr int kSecondsPerDay = 86400;
|
|
static constexpr int kSecondsPerHour = 3600;
|
|
static constexpr int kSecondsPerMinute = 60;
|
|
|
|
OffpeakTimeOption();
|
|
explicit OffpeakTimeOption(const std::string& offpeak_time_string);
|
|
std::string daily_offpeak_time_utc = "";
|
|
int daily_offpeak_start_time_utc = 0;
|
|
int daily_offpeak_end_time_utc = 0;
|
|
|
|
void SetFromOffpeakTimeString(const std::string& offpeak_time_string);
|
|
|
|
OffpeakTimeInfo GetOffpeakTimeInfo(const int64_t& current_time) const;
|
|
};
|
|
|
|
} // namespace ROCKSDB_NAMESPACE
|