Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for TiKV IO rate limiter #383

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ set(SOURCES
env/env.cc
env/env_chroot.cc
env/env_encryption.cc
env/env_inspected.cc
env/file_system.cc
env/file_system_tracer.cc
env/fs_remap.cc
Expand Down
1 change: 1 addition & 0 deletions TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ cpp_library_wrapper(name="rocksdb_lib", srcs=[
"env/env.cc",
"env/env_chroot.cc",
"env/env_encryption.cc",
"env/env_inspected.cc",
"env/env_posix.cc",
"env/file_system.cc",
"env/file_system_tracer.cc",
Expand Down
39 changes: 39 additions & 0 deletions env/env_basic_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "rocksdb/convenience.h"
#include "rocksdb/env.h"
#include "rocksdb/env_encryption.h"
#include "rocksdb/env_inspected.h"
#include "test_util/testharness.h"

namespace ROCKSDB_NAMESPACE {
Expand Down Expand Up @@ -81,6 +82,41 @@ static Env* GetTestFS() {
return fs_env;
}

class DummyFileSystemInspector : public FileSystemInspector {
public:
DummyFileSystemInspector(size_t refill_bytes = 0)
: refill_bytes_(refill_bytes) {}

Status Read(size_t len, size_t* allowed) override {
assert(allowed);
if (refill_bytes_ == 0) {
*allowed = len;
} else {
*allowed = std::min(refill_bytes_, len);
}
return Status::OK();
}

Status Write(size_t len, size_t* allowed) override {
assert(allowed);
if (refill_bytes_ == 0) {
*allowed = len;
} else {
*allowed = std::min(refill_bytes_, len);
}
return Status::OK();
}

private:
size_t refill_bytes_;
};

static Env* GetInspectedEnv() {
static std::unique_ptr<Env> inspected_env(NewFileSystemInspectedEnv(
Env::Default(), std::make_shared<DummyFileSystemInspector>(1)));
return inspected_env.get();
}

} // namespace
class EnvBasicTestWithParam
: public testing::Test,
Expand Down Expand Up @@ -118,6 +154,9 @@ INSTANTIATE_TEST_CASE_P(EncryptedEnv, EnvMoreTestWithParam,
INSTANTIATE_TEST_CASE_P(MemEnv, EnvBasicTestWithParam,
::testing::Values(&GetMemoryEnv));

INSTANTIATE_TEST_CASE_P(InspectedEnv, EnvBasicTestWithParam,
::testing::Values(&GetInspectedEnv));

namespace {

// Returns a vector of 0 or 1 Env*, depending whether an Env is registered for
Expand Down
Loading
Loading