Skip to content

Commit

Permalink
Add debug info
Browse files Browse the repository at this point in the history
Signed-off-by: Yang Zhang <[email protected]>
  • Loading branch information
v01dstar committed May 7, 2024
1 parent 808de9d commit 387b78f
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/titan/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ struct TitanCFOptions : public ColumnFamilyOptions {
// support hole punching, such as ext4, xfs, btrfs, etc.
//
// Default: false
bool hole_punching_gc{false};
bool enable_punch_hole_gc{false};

TitanCFOptions() = default;
explicit TitanCFOptions(const ColumnFamilyOptions& options)
Expand Down
2 changes: 1 addition & 1 deletion src/blob_file_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ BlobFileBuilder::BlobFileBuilder(const TitanDBOptions& db_options,
#endif
}
// alignment_size_ = cf_options_.alignment_size;
alignment_size_ = cf_options.hole_punching_gc ? 4 * 1024 : 0;
alignment_size_ = cf_options.enable_punch_hole_gc ? 4 * 1024 : 0;
WriteHeader();
}

Expand Down
7 changes: 5 additions & 2 deletions src/blob_format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,11 @@ TitanInternalStats::StatsType BlobFileMeta::GetDiscardableRatioLevel() const {
}

void BlobFileMeta::Dump(bool with_keys) const {
fprintf(stdout, "file %" PRIu64 ", size %" PRIu64 ", level %" PRIu32,
file_number_, file_size_, file_level_);
fprintf(stdout,
"file %" PRIu64 ", size %" PRIu64 ", level %" PRIu32
"live blocks %" PRIu64 ", hole punchable blocks %" PRIu64,
file_number_, file_size_, file_level_, live_blocks_.load(),
hole_punchable_blocks_.load());
if (with_keys) {
fprintf(stdout, ", smallest key: %s, largest key: %s",
Slice(smallest_key_).ToString(true /*hex*/).c_str(),
Expand Down
4 changes: 2 additions & 2 deletions src/blob_gc_job_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ TEST_F(BlobGCJobTest, PunchHole) {
rocksdb::SyncPoint::GetInstance()->EnableProcessing();

DisableMergeSmall();
options_.hole_punching_gc = true;
options_.enable_punch_hole_gc = true;
options_.disable_background_gc = false;
options_.disable_auto_compactions = false;

Expand Down Expand Up @@ -340,7 +340,7 @@ TEST_F(BlobGCJobTest, PunchHole) {
ASSERT_EQ(value, values[i]);
}
}
options_.hole_punching_gc = false;
options_.enable_punch_hole_gc = false;
options_.disable_background_gc = true;
options_.disable_auto_compactions = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/blob_storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void BlobStorage::ComputeGCScore() {
score = file.second->GetDiscardableRatio();
}
if (score < cf_options_.blob_file_discardable_ratio &&
cf_options_.hole_punching_gc) {
cf_options_.enable_punch_hole_gc) {
auto punch_hole_score = file.second->GetPunchHoleScore();
if (punch_hole_score > 0) {
GCScore gc_score = {};
Expand Down
2 changes: 2 additions & 0 deletions src/db_impl_gc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ Status TitanDBImpl::BackgroundGC(LogBuffer* log_buffer, BlobGC* blob_gc) {
// Nothing to do
TITAN_LOG_BUFFER(log_buffer, "Titan GC nothing to do");
} else {
TITAN_LOG_BUFFER(log_buffer, "Titan GC start, using punch hole: %s",
blob_gc->use_punch_hole());
StopWatch gc_sw(env_->GetSystemClock().get(), statistics(stats_.get()),
TITAN_GC_MICROS);
BlobGCJob blob_gc_job(blob_gc, db_, &mutex_, db_options_, env_,
Expand Down
5 changes: 5 additions & 0 deletions src/edit_collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ class EditCollector {
file.second);
}
}
for (auto& file : updated_files_) {
if (deleted_files_.count(file.first) == 0) {
file.second->Dump(with_keys);
}
}
}

private:
Expand Down
2 changes: 2 additions & 0 deletions src/options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ void TitanCFOptions::Dump(Logger* logger) const {
}
TITAN_LOG_HEADER(logger, "TitanCFOptions.blob_run_mode : %s",
blob_run_mode_str.c_str());
TITAN_LOG_HEADER(logger, "TitanCFOptions.enable_punch_hole_gc : %s",
enable_punch_hole_gc ? "true" : "false");
}

void TitanCFOptions::UpdateMutableOptions(
Expand Down

0 comments on commit 387b78f

Please sign in to comment.