Skip to content

Commit

Permalink
[opt](index) add more inverted index profile metrics (apache#36696)
Browse files Browse the repository at this point in the history
add more inverted index query profile:
- InvertedIndexQueryNullBitmapTime
- InvertedIndexSearcherCacheHit
- InvertedIndexSearcherCacheMiss
  • Loading branch information
xiaokang authored Aug 5, 2024
1 parent 76c984a commit 6942e16
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 deletions.
3 changes: 3 additions & 0 deletions be/src/olap/olap_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,13 @@ struct OlapReaderStatistics {
int64_t inverted_index_query_timer = 0;
int64_t inverted_index_query_cache_hit = 0;
int64_t inverted_index_query_cache_miss = 0;
int64_t inverted_index_query_null_bitmap_timer = 0;
int64_t inverted_index_query_bitmap_copy_timer = 0;
int64_t inverted_index_query_bitmap_op_timer = 0;
int64_t inverted_index_searcher_open_timer = 0;
int64_t inverted_index_searcher_search_timer = 0;
int64_t inverted_index_searcher_cache_hit = 0;
int64_t inverted_index_searcher_cache_miss = 0;

int64_t output_index_result_column_timer = 0;
// number of segment filtered by column stat when creating seg iterator
Expand Down
8 changes: 6 additions & 2 deletions be/src/olap/rowset/segment_v2/inverted_index_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,10 @@ void InvertedIndexReader::get_analyse_result(std::vector<std::string>& analyse_r
}
}

Status InvertedIndexReader::read_null_bitmap(InvertedIndexQueryCacheHandle* cache_handle,
Status InvertedIndexReader::read_null_bitmap(OlapReaderStatistics* stats,
InvertedIndexQueryCacheHandle* cache_handle,
lucene::store::Directory* dir) {
SCOPED_RAW_TIMER(&stats->inverted_index_query_null_bitmap_timer);
lucene::store::IndexInput* null_bitmap_in = nullptr;
bool owned_dir = false;
try {
Expand Down Expand Up @@ -244,9 +246,11 @@ Status InvertedIndexReader::handle_searcher_cache(
InvertedIndexSearcherCache::CacheKey searcher_cache_key(index_file_key);
if (InvertedIndexSearcherCache::instance()->lookup(searcher_cache_key,
inverted_index_cache_handle)) {
stats->inverted_index_searcher_cache_hit++;
return Status::OK();
} else {
// searcher cache miss
stats->inverted_index_searcher_cache_miss++;
auto mem_tracker = std::make_unique<MemTracker>("InvertedIndexSearcherCacheWithRead");
SCOPED_RAW_TIMER(&stats->inverted_index_searcher_open_timer);
IndexSearcherPtr searcher;
Expand All @@ -256,7 +260,7 @@ Status InvertedIndexReader::handle_searcher_cache(
// to avoid open directory additionally for null_bitmap
// TODO: handle null bitmap procedure in new format.
InvertedIndexQueryCacheHandle null_bitmap_cache_handle;
static_cast<void>(read_null_bitmap(&null_bitmap_cache_handle, dir.get()));
static_cast<void>(read_null_bitmap(stats, &null_bitmap_cache_handle, dir.get()));
RETURN_IF_ERROR(create_index_searcher(dir.release(), &searcher, mem_tracker.get(), type()));
auto* cache_value = new InvertedIndexSearcherCache::CacheValue(
std::move(searcher), mem_tracker->consumption(), UnixMillis());
Expand Down
5 changes: 3 additions & 2 deletions be/src/olap/rowset/segment_v2/inverted_index_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ class InvertedIndexReader : public std::enable_shared_from_this<InvertedIndexRea
const void* query_value, InvertedIndexQueryType query_type,
uint32_t* count) = 0;

Status read_null_bitmap(InvertedIndexQueryCacheHandle* cache_handle,
Status read_null_bitmap(OlapReaderStatistics* stats,
InvertedIndexQueryCacheHandle* cache_handle,
lucene::store::Directory* dir = nullptr);

virtual InvertedIndexReaderType type() = 0;
Expand Down Expand Up @@ -372,7 +373,7 @@ class InvertedIndexIterator {

Status read_null_bitmap(InvertedIndexQueryCacheHandle* cache_handle,
lucene::store::Directory* dir = nullptr) {
return _reader->read_null_bitmap(cache_handle, dir);
return _reader->read_null_bitmap(_stats, cache_handle, dir);
}

[[nodiscard]] InvertedIndexReaderType get_inverted_index_reader_type() const;
Expand Down
6 changes: 6 additions & 0 deletions be/src/pipeline/exec/olap_scan_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ Status OlapScanLocalState::_init_profile() {
_inverted_index_query_cache_miss_counter =
ADD_COUNTER(_segment_profile, "InvertedIndexQueryCacheMiss", TUnit::UNIT);
_inverted_index_query_timer = ADD_TIMER(_segment_profile, "InvertedIndexQueryTime");
_inverted_index_query_null_bitmap_timer =
ADD_TIMER(_segment_profile, "InvertedIndexQueryNullBitmapTime");
_inverted_index_query_bitmap_copy_timer =
ADD_TIMER(_segment_profile, "InvertedIndexQueryBitmapCopyTime");
_inverted_index_query_bitmap_op_timer =
Expand All @@ -137,6 +139,10 @@ Status OlapScanLocalState::_init_profile() {
ADD_TIMER(_segment_profile, "InvertedIndexSearcherOpenTime");
_inverted_index_searcher_search_timer =
ADD_TIMER(_segment_profile, "InvertedIndexSearcherSearchTime");
_inverted_index_searcher_cache_hit_counter =
ADD_COUNTER(_segment_profile, "InvertedIndexSearcherCacheHit", TUnit::UNIT);
_inverted_index_searcher_cache_miss_counter =
ADD_COUNTER(_segment_profile, "InvertedIndexSearcherCacheMiss", TUnit::UNIT);

_output_index_result_column_timer = ADD_TIMER(_segment_profile, "OutputIndexResultColumnTimer");

Expand Down
3 changes: 3 additions & 0 deletions be/src/pipeline/exec/olap_scan_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,16 @@ class OlapScanLocalState final : public ScanLocalState<OlapScanLocalState> {

RuntimeProfile::Counter* _inverted_index_filter_counter = nullptr;
RuntimeProfile::Counter* _inverted_index_filter_timer = nullptr;
RuntimeProfile::Counter* _inverted_index_query_null_bitmap_timer = nullptr;
RuntimeProfile::Counter* _inverted_index_query_cache_hit_counter = nullptr;
RuntimeProfile::Counter* _inverted_index_query_cache_miss_counter = nullptr;
RuntimeProfile::Counter* _inverted_index_query_timer = nullptr;
RuntimeProfile::Counter* _inverted_index_query_bitmap_copy_timer = nullptr;
RuntimeProfile::Counter* _inverted_index_query_bitmap_op_timer = nullptr;
RuntimeProfile::Counter* _inverted_index_searcher_open_timer = nullptr;
RuntimeProfile::Counter* _inverted_index_searcher_search_timer = nullptr;
RuntimeProfile::Counter* _inverted_index_searcher_cache_hit_counter = nullptr;
RuntimeProfile::Counter* _inverted_index_searcher_cache_miss_counter = nullptr;

RuntimeProfile::Counter* _output_index_result_column_timer = nullptr;

Expand Down
6 changes: 6 additions & 0 deletions be/src/vec/exec/scan/new_olap_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,8 @@ void NewOlapScanner::_collect_profile_before_close() {
COUNTER_UPDATE(Parent->_inverted_index_query_cache_miss_counter, \
stats.inverted_index_query_cache_miss); \
COUNTER_UPDATE(Parent->_inverted_index_query_timer, stats.inverted_index_query_timer); \
COUNTER_UPDATE(Parent->_inverted_index_query_null_bitmap_timer, \
stats.inverted_index_query_null_bitmap_timer); \
COUNTER_UPDATE(Parent->_inverted_index_query_bitmap_copy_timer, \
stats.inverted_index_query_bitmap_copy_timer); \
COUNTER_UPDATE(Parent->_inverted_index_query_bitmap_op_timer, \
Expand All @@ -649,6 +651,10 @@ void NewOlapScanner::_collect_profile_before_close() {
stats.inverted_index_searcher_open_timer); \
COUNTER_UPDATE(Parent->_inverted_index_searcher_search_timer, \
stats.inverted_index_searcher_search_timer); \
COUNTER_UPDATE(Parent->_inverted_index_searcher_cache_hit_counter, \
stats.inverted_index_searcher_cache_hit); \
COUNTER_UPDATE(Parent->_inverted_index_searcher_cache_miss_counter, \
stats.inverted_index_searcher_cache_miss); \
if (config::enable_file_cache) { \
io::FileCacheProfileReporter cache_profile(Parent->_segment_profile.get()); \
cache_profile.update(&stats.file_cache_stats); \
Expand Down

0 comments on commit 6942e16

Please sign in to comment.