Skip to content

Commit 7aa135e

Browse files
authored
24-3 Report index sizes by type (#8325)
1 parent 57fe08e commit 7aa135e

File tree

7 files changed

+26
-9
lines changed

7 files changed

+26
-9
lines changed

ydb/core/tablet_flat/flat_database.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ ui64 TDatabase::GetTableMemOpsCount(ui32 tableId) const {
494494
}
495495

496496
ui64 TDatabase::GetTableIndexSize(ui32 tableId) const {
497-
return Require(tableId)->Stat().Parts.IndexBytes;
497+
const auto& partStats = Require(tableId)->Stat().Parts;
498+
return partStats.FlatIndexBytes + partStats.BTreeIndexBytes;
498499
}
499500

500501
ui64 TDatabase::GetTableSearchHeight(ui32 tableId) const {

ydb/core/tablet_flat/flat_dbase_misc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace NTable {
1414

1515
void Describe(IOutputStream &out) const noexcept
1616
{
17-
const ui64 sys = Parts.IndexBytes + Parts.ByKeyBytes + Parts.OtherBytes;
17+
const ui64 sys = Parts.FlatIndexBytes + Parts.BTreeIndexBytes + Parts.ByKeyBytes + Parts.OtherBytes;
1818

1919
out
2020
<< "DBase{" << Tables << "t " << Parts.PartsCount << "p"

ydb/core/tablet_flat/flat_executor.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3590,7 +3590,9 @@ void TExecutor::UpdateCounters(const TActorContext &ctx) {
35903590
{ /* Memory consumption of common for leader and follower components */
35913591
Counters->Simple()[TExecutorCounters::DB_WARM_BYTES].Set(dbCounters.MemTableBytes);
35923592
Counters->Simple()[TExecutorCounters::DB_META_BYTES].Set(Stats->PacksMetaBytes);
3593-
Counters->Simple()[TExecutorCounters::DB_INDEX_BYTES].Set(dbCounters.Parts.IndexBytes);
3593+
Counters->Simple()[TExecutorCounters::DB_FLAT_INDEX_BYTES].Set(dbCounters.Parts.FlatIndexBytes);
3594+
Counters->Simple()[TExecutorCounters::DB_B_TREE_INDEX_BYTES].Set(dbCounters.Parts.BTreeIndexBytes);
3595+
Counters->Simple()[TExecutorCounters::DB_INDEX_BYTES].Set(dbCounters.Parts.FlatIndexBytes + dbCounters.Parts.BTreeIndexBytes);
35943596
Counters->Simple()[TExecutorCounters::DB_OTHER_BYTES].Set(dbCounters.Parts.OtherBytes);
35953597
Counters->Simple()[TExecutorCounters::DB_BYKEY_BYTES].Set(dbCounters.Parts.ByKeyBytes);
35963598
Counters->Simple()[TExecutorCounters::USED_TABLET_MEMORY].Set(UsedTabletMemory);

ydb/core/tablet_flat/flat_executor_counters.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ namespace NTabletFlatExecutor {
6262
XX(CONSUMED_STORAGE, "ConsumedStorage") \
6363
XX(CONSUMED_MEMORY, "ConsumedMemory") \
6464
XX(COMPACTION_READ_IN_FLY, "CompactionReadInFly") \
65+
XX(DB_FLAT_INDEX_BYTES, "DbFlatIndexBytes") \
66+
XX(DB_B_TREE_INDEX_BYTES, "DbBTreeIndexBytes") \
6567

6668
// don't change order!
6769
#define FLAT_EXECUTOR_CUMULATIVE_COUNTERS_MAP(XX) \

ydb/core/tablet_flat/flat_table.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,11 @@ void TTable::SetTableObserver(TIntrusivePtr<ITableObserver> ptr) noexcept
14151415
void TPartStats::Add(const TPartView& partView)
14161416
{
14171417
PartsCount += 1;
1418-
IndexBytes += partView->IndexesRawSize;
1418+
if (partView->IndexPages.HasBTree()) {
1419+
BTreeIndexBytes += partView->IndexesRawSize;
1420+
} else {
1421+
FlatIndexBytes += partView->IndexesRawSize;
1422+
}
14191423
ByKeyBytes += partView->ByKey ? partView->ByKey->Raw.size() : 0;
14201424
PlainBytes += partView->Stat.Bytes;
14211425
CodedBytes += partView->Stat.Coded;
@@ -1434,7 +1438,11 @@ void TPartStats::Add(const TPartView& partView)
14341438
bool TPartStats::Remove(const TPartView& partView)
14351439
{
14361440
NUtil::SubSafe(PartsCount, ui64(1));
1437-
NUtil::SubSafe(IndexBytes, partView->IndexesRawSize);
1441+
if (partView->IndexPages.HasBTree()) {
1442+
NUtil::SubSafe(BTreeIndexBytes, partView->IndexesRawSize);
1443+
} else {
1444+
NUtil::SubSafe(FlatIndexBytes, partView->IndexesRawSize);
1445+
}
14381446
NUtil::SubSafe(ByKeyBytes, partView->ByKey ? partView->ByKey->Raw.size() : 0);
14391447
NUtil::SubSafe(PlainBytes, partView->Stat.Bytes);
14401448
NUtil::SubSafe(CodedBytes, partView->Stat.Coded);
@@ -1463,7 +1471,8 @@ bool TPartStats::Remove(const TPartView& partView)
14631471
TPartStats& TPartStats::operator+=(const TPartStats& rhs)
14641472
{
14651473
PartsCount += rhs.PartsCount;
1466-
IndexBytes += rhs.IndexBytes;
1474+
FlatIndexBytes += rhs.FlatIndexBytes;
1475+
BTreeIndexBytes += rhs.BTreeIndexBytes;
14671476
OtherBytes += rhs.OtherBytes;
14681477
ByKeyBytes += rhs.ByKeyBytes;
14691478
PlainBytes += rhs.PlainBytes;
@@ -1480,7 +1489,8 @@ TPartStats& TPartStats::operator+=(const TPartStats& rhs)
14801489
TPartStats& TPartStats::operator-=(const TPartStats& rhs)
14811490
{
14821491
NUtil::SubSafe(PartsCount, rhs.PartsCount);
1483-
NUtil::SubSafe(IndexBytes, rhs.IndexBytes);
1492+
NUtil::SubSafe(FlatIndexBytes, rhs.FlatIndexBytes);
1493+
NUtil::SubSafe(BTreeIndexBytes, rhs.BTreeIndexBytes);
14841494
NUtil::SubSafe(OtherBytes, rhs.OtherBytes);
14851495
NUtil::SubSafe(ByKeyBytes, rhs.ByKeyBytes);
14861496
NUtil::SubSafe(PlainBytes, rhs.PlainBytes);

ydb/core/tablet_flat/flat_table_stats.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ namespace NTable {
88

99
struct TPartStats {
1010
ui64 PartsCount = 0; /* Total used TPart units in db */
11-
ui64 IndexBytes = 0;
11+
ui64 FlatIndexBytes = 0;
12+
ui64 BTreeIndexBytes = 0;
1213
ui64 OtherBytes = 0; /* Other metadata and sys. indexes */
1314
ui64 ByKeyBytes = 0;
1415
ui64 PlainBytes = 0; /* Plain data pages size */

ydb/core/tablet_flat/ut/ut_db_iface.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ Y_UNIT_TEST_SUITE(DBase) {
276276
UNIT_ASSERT(me->Counters().Parts.RowsErase == 0);
277277
UNIT_ASSERT(me->Counters().Parts.PartsCount == 0);
278278
UNIT_ASSERT(me->Counters().Parts.PlainBytes == 0);
279-
UNIT_ASSERT(me->Counters().Parts.IndexBytes == 0);
279+
UNIT_ASSERT(me->Counters().Parts.FlatIndexBytes == 0);
280+
UNIT_ASSERT(me->Counters().Parts.BTreeIndexBytes == 0);
280281
UNIT_ASSERT(me->Counters().Parts.OtherBytes == 0);
281282
}
282283

0 commit comments

Comments
 (0)