Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
hx235 committed Oct 29, 2024
1 parent e00ba7f commit d35b72b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
3 changes: 2 additions & 1 deletion db/db_impl/db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5637,7 +5637,8 @@ void DBImpl::EraseThreadStatusDbInfo() const {}
//
// A global method that can dump out the build version
void DumpRocksDBBuildVersion(Logger* log) {
ROCKS_LOG_HEADER(log, "RocksDB version: %s\n",
ROCKS_LOG_HEADER(log,
"RocksDB version: %s with debugging info for readahead\n",
GetRocksVersionAsString().c_str());
const auto& props = GetRocksBuildProperties();
const auto& sha = props.find("rocksdb_build_git_sha");
Expand Down
26 changes: 26 additions & 0 deletions table/block_based/block_based_table_iterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ void BlockBasedTableIterator::SeekImpl(const Slice* target,
prefix_extractor_->InDomain(seek_user_key)
? prefix_extractor_->Transform(seek_user_key).ToString()
: "";
Logger* info_log = table_->GetInfoLog();
if (info_log != nullptr) {
if (seek_key_prefix_for_readahead_trimming_ == "") {
ROCKS_LOG_INFO(info_log,
"seek_key_prefix_for_readahead_trimming_ not set");
} else {
ROCKS_LOG_INFO(info_log, "seek_key_prefix_for_readahead_trimming_ set");
}
}
}

bool is_first_pass = !async_read_in_progress_;
Expand All @@ -63,6 +72,23 @@ void BlockBasedTableIterator::SeekImpl(const Slice* target,
table_->get_rep()->table_options.block_cache.get() &&
direction_ == IterDirection::kForward) {
readahead_cache_lookup_ = true;
} else {
Logger* info_log = table_->GetInfoLog();
if (info_log != nullptr) {
ROCKS_LOG_INFO(info_log, "No readahead cache lookup");
ROCKS_LOG_INFO(
info_log,
"autotune_readaheadsize: %s is_first_pass: %s auto_readahead_size: "
"%s iterate_upper_bound: %s prefix_same_as_start: %s block_cache: %s "
"direction: %s",
autotune_readaheadsize ? "true" : "false",
is_first_pass ? "true" : "false",
read_options_.auto_readahead_size ? "true" : "false",
read_options_.iterate_upper_bound ? "true" : "false",
read_options_.prefix_same_as_start ? "true" : "false",
table_->get_rep()->table_options.block_cache.get() ? "true" : "false",
direction_ == IterDirection::kForward ? "Forward" : "Non forward");
}
}

is_out_of_bound_ = false;
Expand Down
11 changes: 11 additions & 0 deletions table/block_based/block_based_table_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <deque>

#include "db/seqno_to_time_mapping.h"
#include "logging/logging.h"
#include "table/block_based/block_based_table_reader.h"
#include "table/block_based/block_based_table_reader_impl.h"
#include "table/block_based/block_prefetcher.h"
Expand Down Expand Up @@ -414,6 +415,7 @@ class BlockBasedTableIterator : public InternalIteratorBase<Slice> {
}

bool IsNextBlockOutOfReadaheadBound() {
Logger* info_log = table_->GetInfoLog();
const Slice& index_iter_user_key = index_iter_->user_key();
// If curr block's index key >= iterate_upper_bound, it means all the keys
// in next block or above are out of bound.
Expand All @@ -426,6 +428,9 @@ class BlockBasedTableIterator : public InternalIteratorBase<Slice> {
? true
: false);
if (out_of_upper_bound) {
if (info_log != nullptr) {
ROCKS_LOG_INFO(info_log, "Trim by upper bound");
}
return true;
}

Expand All @@ -444,9 +449,15 @@ class BlockBasedTableIterator : public InternalIteratorBase<Slice> {
/*b_has_ts=*/false) > 0));

if (out_of_prefix_bound) {
if (info_log != nullptr) {
ROCKS_LOG_INFO(info_log, "Trim by upper bound");
}
return true;
}

if (info_log != nullptr) {
ROCKS_LOG_INFO(info_log, "No trim");
}
return false;
}

Expand Down
2 changes: 2 additions & 0 deletions table/block_based/block_based_table_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,8 @@ bool BlockBasedTable::IsLastLevel() const {
return rep_->level == rep_->ioptions.num_levels - 1;
}

Logger* BlockBasedTable::GetInfoLog() const { return rep_->ioptions.logger; }

InternalIterator* BlockBasedTable::NewIterator(
const ReadOptions& read_options, const SliceTransform* prefix_extractor,
Arena* arena, bool skip_filters, TableReaderCaller caller,
Expand Down
2 changes: 2 additions & 0 deletions table/block_based/block_based_table_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class BlockBasedTable : public TableReader {
BlockCacheLookupContext* lookup_context,
bool* filter_checked) const;

Logger* GetInfoLog() const;

// Returns a new iterator over the table contents.
// The result of NewIterator() is initially invalid (caller must
// call one of the Seek methods on the iterator before using it).
Expand Down

0 comments on commit d35b72b

Please sign in to comment.