Skip to content

Commit

Permalink
Reduce huge amount of PDisk's chunks info printed into log (ydb-platf…
Browse files Browse the repository at this point in the history
…orm#8699)

Co-authored-by: Vlad Kuznecov <[email protected]>
  • Loading branch information
va-kuznecov and Vlad Kuznecov authored Sep 4, 2024
1 parent 55fc639 commit 5f731ba
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,28 @@ bool TPDisk::ProcessChunk0(const NPDisk::TEvReadLogResult &readLogResult, TStrin
return true;
}

static void PrintCondensedChunksList(TStringStream& str, const std::vector<ui32>& chunks) {
str << " [";
bool first = true;
std::optional<TChunkIdx> begin;
for (size_t i = 0; i < chunks.size(); ++i) {
if (!begin) {
begin = chunks[i];
}
if (i + 1 < chunks.size() && chunks[i] + 1 == chunks[i + 1]) {
continue;
}
str << (std::exchange(first, false) ? "" : " ");
if (*begin == chunks[i]) {
str << chunks[i];
} else {
str << *begin << "-" << chunks[i];
}
begin.reset();
}
str << "];";
}

void TPDisk::PrintChunksDebugInfo() {
auto print = [&] () {
std::map<TOwner, std::vector<ui32>> ownerToChunks;
Expand All @@ -487,17 +509,13 @@ void TPDisk::PrintChunksDebugInfo() {
str << "PDiskId# " << PDiskId << " PrintChunksDebugInfo; ";
for (auto& [owner, chunks] : ownerToChunks) {
std::sort(chunks.begin(), chunks.end());
str << " Owner# " << owner << " [";
bool first = true;
for (auto idx : chunks) {
str << (std::exchange(first, false) ? "" : " ") << idx;
}
str << "];";
str << " Owner# " << owner;
PrintCondensedChunksList(str, chunks);
}
return str.Str();
};

LOG_INFO_S(*ActorSystem, NKikimrServices::BS_PDISK, print());
LOG_DEBUG_S(*ActorSystem, NKikimrServices::BS_PDISK, print());
}

TRcBuf TPDisk::ProcessReadSysLogResult(ui64 &outWritePosition, ui64 &outLsn,
Expand Down

0 comments on commit 5f731ba

Please sign in to comment.