gavinchou commented on code in PR #51573: URL: https://github.com/apache/doris/pull/51573#discussion_r2142620041
########## be/src/cloud/cloud_tablet.cpp: ########## @@ -538,12 +553,16 @@ void CloudTablet::remove_unused_rowsets() { auto& key_ranges = std::get<1>(*it); tablet_meta()->delete_bitmap().remove(key_ranges); it = _unused_delete_bitmap.erase(it); + removed_delete_bitmap_num++; } - if (!_unused_rowsets.empty() || !_unused_delete_bitmap.empty()) { + if (removed_rowsets_num > 0 || removed_delete_bitmap_num > 0) { Review Comment: why not just LOG without this check? what's the cost? ########## be/src/cloud/cloud_tablet.cpp: ########## @@ -504,19 +504,34 @@ bool CloudTablet::need_remove_unused_rowsets() { return !_unused_rowsets.empty() || !_unused_delete_bitmap.empty(); } +void CloudTablet::add_unused_rowsets(const std::vector<RowsetSharedPtr>& rowsets) { + std::lock_guard<std::mutex> lock(_gc_mutex); + for (const auto& rowset : rowsets) { + _unused_rowsets[rowset->rowset_id()] = rowset; + } + g_unused_rowsets_count << rowsets.size(); Review Comment: also record size in bytes ########## be/src/cloud/cloud_tablet.cpp: ########## @@ -342,17 +344,20 @@ void CloudTablet::add_rowsets(std::vector<RowsetSharedPtr> to_add, bool version_ // replace existed rowset with `to_add` rowset. This may occur when: // 1. schema change converts rowsets which have been double written to new tablet // 2. cumu compaction picks single overlapping input rowset to perform compaction - if (keys_type() == UNIQUE_KEYS && enable_unique_key_merge_on_write()) { - // add existed rowset to unused_rowsets to remove delete bitmap - if (auto find_it = _rs_version_map.find(rs->version()); - find_it != _rs_version_map.end()) { - DCHECK(find_it->second->rowset_id() != rs->rowset_id()) - << "tablet_id=" << tablet_id() - << ", rowset_id=" << rs->rowset_id().to_string() - << ", existed rowset=" << find_it->second->rowset_id().to_string(); - _unused_rowsets.emplace(find_it->second->rowset_id(), find_it->second); - } + + // add existed rowset to unused_rowsets to remove delete bitmap and recycle cached data + + std::vector<RowsetSharedPtr> unused_rowsets; + if (auto find_it = _rs_version_map.find(rs->version()); + find_it != _rs_version_map.end()) { + DCHECK(find_it->second->rowset_id() != rs->rowset_id()) Review Comment: add a `if()` to check and log ? ########## be/src/cloud/cloud_tablet.cpp: ########## @@ -63,6 +63,8 @@ bvar::LatencyRecorder g_cu_compaction_get_delete_bitmap_lock_time_ms( bvar::LatencyRecorder g_base_compaction_get_delete_bitmap_lock_time_ms( "base_compaction_get_delete_bitmap_lock_time_ms"); +bvar::Adder<int64_t> g_unused_rowsets_count("unused_rowsets_count"); Review Comment: also record size in bytes? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org