Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chunks count for limit in compaction #10812

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ydb/core/tx/columnshard/counters/portions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ void TSimplePortionsGroupInfo::AddPortion(const TPortionInfo& p) {
RawBytes += p.GetTotalRawBytes();
Count += 1;
RecordsCount += p.NumRows();
ChunksCount += p.GetChunksCount();
}

void TSimplePortionsGroupInfo::RemovePortion(const std::shared_ptr<TPortionInfo>& p) {
Expand All @@ -41,10 +42,12 @@ void TSimplePortionsGroupInfo::RemovePortion(const TPortionInfo& p) {
RawBytes -= p.GetTotalRawBytes();
Count -= 1;
RecordsCount -= p.NumRows();
ChunksCount -= p.GetChunksCount();
AFL_VERIFY(RawBytes >= 0);
AFL_VERIFY(BlobBytes >= 0);
AFL_VERIFY(Count >= 0);
AFL_VERIFY(RecordsCount >= 0);
AFL_VERIFY(ChunksCount >= 0);
}

} // namespace NKikimr::NOlap
3 changes: 3 additions & 0 deletions ydb/core/tx/columnshard/counters/portions.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class TSimplePortionsGroupInfo {
YDB_READONLY(i64, RawBytes, 0);
YDB_READONLY(i64, Count, 0);
YDB_READONLY(i64, RecordsCount, 0);
YDB_READONLY(i64, ChunksCount, 0);

public:
NJson::TJsonValue SerializeToJson() const {
Expand All @@ -23,6 +24,7 @@ class TSimplePortionsGroupInfo {
result.InsertValue("raw_bytes", RawBytes);
result.InsertValue("count", Count);
result.InsertValue("records_count", RecordsCount);
result.InsertValue("chunks_count", ChunksCount);
return result;
}

Expand All @@ -45,6 +47,7 @@ class TSimplePortionsGroupInfo {
result.RawBytes = RawBytes + item.RawBytes;
result.Count = Count + item.Count;
result.RecordsCount = RecordsCount + item.RecordsCount;
result.ChunksCount = ChunksCount + item.ChunksCount;
return result;
}

Expand Down
4 changes: 4 additions & 0 deletions ydb/core/tx/columnshard/engines/portions/portion_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ class TPortionInfo {

bool NeedShardingFilter(const TGranuleShardingInfo& shardingInfo) const;

ui64 GetChunksCount() const {
return Records.size() + Indexes.size();
}

NSplitter::TEntityGroups GetEntityGroupsByStorageId(
const TString& specialTier, const IStoragesManager& storages, const TIndexInfo& indexInfo) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ class TCompactionTaskData {
}

bool CanTakeMore() const {
return MemoryUsage < (((ui64)512) << 20) && Portions.size() < 10000;
if (Portions.size() <= 1) {
return true;
}
return MemoryUsage < (((ui64)512) << 20) && CurrentLevelPortionsInfo.GetChunksCount() + TargetLevelPortionsInfo.GetChunksCount() < 100000
&& Portions.size() < 10000;
}

TCompactionTaskData(const ui64 targetCompactionLevel)
Expand Down
Loading