Skip to content

Commit be37732

Browse files
author
jcarin
committed
Load Cachestream singleton at DB open, rather than on compaction
1 parent 428992b commit be37732

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

cachestream/cachestream.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,4 @@ void Cachestream::remove_tgid(int tgid) {
181181
}
182182
}
183183

184-
} // namespace ROCKSDB_NAMESPACE
184+
} // namespace ROCKSDB_NAMESPACE

db/compaction/compaction_job.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
#include "cachestream/cachestream.h"
6161
#include <sys/syscall.h>
6262

63+
#include <iostream>
64+
6365
namespace ROCKSDB_NAMESPACE {
6466

6567
const char* GetCompactionReasonString(CompactionReason compaction_reason) {
@@ -719,9 +721,6 @@ Status CompactionJob::Run() {
719721
compact_->compaction->mutable_cf_options()->prefix_extractor;
720722
std::atomic<size_t> next_file_idx(0);
721723
auto verify_table = [&](Status& output_status) {
722-
auto& cachestream = Cachestream::getInstance();
723-
int tid = syscall(SYS_gettid);
724-
CachestreamTidGuard tid_guard(cachestream, tid);
725724

726725
while (true) {
727726
size_t file_idx = next_file_idx.fetch_add(1);
@@ -1082,7 +1081,6 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) {
10821081
assert(sub_compact);
10831082
assert(sub_compact->compaction);
10841083

1085-
// Add current thread's TID to cachestream map using RAII
10861084
auto& cachestream = Cachestream::getInstance();
10871085
int tid = syscall(SYS_gettid);
10881086
CachestreamTidGuard tid_guard(cachestream, tid);

db/db_impl/db_impl_open.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include "util/string_util.h"
2929
#include "util/udt_util.h"
3030

31+
#include "cachestream/cachestream.h"
32+
3133
namespace ROCKSDB_NAMESPACE {
3234
Options SanitizeOptions(const std::string& dbname, const Options& src,
3335
bool read_only, Status* logger_creation_s) {
@@ -1952,6 +1954,9 @@ Status DBImpl::Open(const DBOptions& db_options, const std::string& dbname,
19521954
assert(handles);
19531955
handles->clear();
19541956

1957+
// Initialize Cachestream singleton, joins cgroup and loads BPF program.
1958+
Cachestream::getInstance();
1959+
19551960
size_t max_write_buffer_size = 0;
19561961
for (auto cf : column_families) {
19571962
max_write_buffer_size =

0 commit comments

Comments
 (0)