Skip to content

Commit e72e2dd

Browse files
authored
Count Rounds from 1 again to prevent N+1 rounds instead of requested N (#19154) (#20237)
1 parent 73c2345 commit e72e2dd

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

ydb/core/tx/datashard/build_index/local_kmeans.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ class TLocalKMeansScan: public TActor<TLocalKMeansScan>, public IActorExceptionH
379379
}
380380
bool ok = Clusters->SetClusters(std::move(rows));
381381
Y_ENSURE(ok);
382+
Clusters->SetRound(1);
382383
return false; // do KMEANS
383384
}
384385

ydb/core/tx/datashard/build_index/prefix_kmeans.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ class TPrefixKMeansScan: public TActor<TPrefixKMeansScan>, public IActorExceptio
425425
}
426426
bool ok = Clusters->SetClusters(std::move(rows));
427427
Y_ENSURE(ok);
428+
Clusters->SetRound(1);
428429
return false; // do KMEANS
429430
}
430431

ydb/core/tx/schemeshard/schemeshard_build_index__progress.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,12 +1090,12 @@ struct TSchemeShard::TIndexBuilder::TTxProgress: public TSchemeShard::TIndexBuil
10901090
if (buildInfo.KMeans.Rounds > 1) {
10911091
LOG_D("FillVectorIndex Recompute " << buildInfo.DebugString());
10921092
buildInfo.KMeans.State = TIndexBuildInfo::TKMeans::Recompute;
1093-
buildInfo.KMeans.Round = 0;
1093+
buildInfo.KMeans.Round = 1;
10941094
// Initialize Clusters
10951095
NIceDb::TNiceDb db(txc.DB);
10961096
buildInfo.Sample.MakeStrictTop(buildInfo.KMeans.K);
10971097
Self->PersistBuildIndexSampleToClusters(db, buildInfo);
1098-
buildInfo.Clusters->SetRound(0);
1098+
buildInfo.Clusters->SetRound(1);
10991099
PersistKMeansState(txc, buildInfo);
11001100
Progress(BuildId);
11011101
} else {

ydb/core/tx/schemeshard/ut_index_build/ut_vector_index_build.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,8 @@ Y_UNIT_TEST_SUITE (VectorIndexBuildTest) {
549549
UNIT_ASSERT_VALUES_EQUAL(readRows, expectedReadRows);
550550
UNIT_ASSERT_VALUES_EQUAL(readBytes, expectedReadBytes);
551551

552-
// every RECOMPUTE round reads table once, no writes; there are 4 recompute rounds:
553-
for (ui32 round = 0; round < 4; round++) {
552+
// every RECOMPUTE round reads table once, no writes; there are 3 recompute rounds:
553+
for (ui32 round = 0; round < 3; round++) {
554554
for (ui32 shard = 0; shard < 3; shard++) {
555555
runtime.WaitFor("recomputeK", [&]{ return recomputeKBlocker.size(); });
556556
recomputeKBlocker.Unblock();
@@ -621,9 +621,9 @@ Y_UNIT_TEST_SUITE (VectorIndexBuildTest) {
621621
expectedUploadRows += level2clusters;
622622
expectedUploadBytes += level2clusters * levelRowBytes;
623623
if (smallScanBuffer) {
624-
// KMEANS reads build table 6 times (SAMPLE + KMEANS * 4 + UPLOAD):
625-
expectedReadRows += tableRows * 6;
626-
expectedReadBytes += buildBytes * 6;
624+
// KMEANS reads build table 5 times (SAMPLE + KMEANS * 3 + UPLOAD):
625+
expectedReadRows += tableRows * 5;
626+
expectedReadBytes += buildBytes * 5;
627627
} else {
628628
// KMEANS reads build table once:
629629
expectedReadRows += tableRows;

0 commit comments

Comments
 (0)