Skip to content

improve optimizer performance #4776

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

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -462,14 +462,17 @@ class TPortionsPool {
}
}

void Actualize(const TInstant currentInstant) {
[[nodiscard]] TInstant Actualize(const TInstant currentInstant) {
TInstant result = TInstant::Max();
auto border = GetFutureBorder();
if (border) {
for (auto&& i : Futures) {
if (currentInstant - i.first >= FutureDetector) {
for (auto&& p : i.second) {
AFL_VERIFY(AddPreActual(p.second));
}
} else {
result = std::min(result, i.first + FutureDetector);
}
}
while (Futures.size() && currentInstant - Futures.begin()->first >= FutureDetector) {
Expand Down Expand Up @@ -501,6 +504,7 @@ class TPortionsPool {
AFL_VERIFY(RemoveActual(i));
}
}
return result;
}

void SplitTo(TPortionsPool& dest, const NArrow::TReplaceKey& destStart) {
Expand Down Expand Up @@ -626,6 +630,7 @@ class TPortionsBucket: public TMoveOnly {
const std::shared_ptr<TCounters> Counters;
mutable std::optional<i64> LastWeight;
TPortionsPool Others;
TInstant NextActualizeInstant = TInstant::Zero();
std::optional<NArrow::TReplaceKey> NextBorder;

void MoveNextBorderTo(TPortionsBucket& dest) {
Expand All @@ -652,11 +657,11 @@ class TPortionsBucket: public TMoveOnly {
public:
class TModificationGuard: TNonCopyable {
private:
const TPortionsBucket& Owner;
TPortionsBucket& Owner;
const bool IsEmptyOthers = false;
const bool HasNextBorder = false;
public:
TModificationGuard(const TPortionsBucket& owner)
TModificationGuard(TPortionsBucket& owner)
: Owner(owner)
, IsEmptyOthers(Owner.Others.ActualsEmpty())
, HasNextBorder(Owner.NextBorder)
Expand All @@ -666,6 +671,7 @@ class TPortionsBucket: public TMoveOnly {

~TModificationGuard() {
AFL_VERIFY_DEBUG(Owner.Validate());
Owner.NextActualizeInstant = TInstant::Zero();
if (!Owner.MainPortion) {
return;
}
Expand Down Expand Up @@ -850,15 +856,15 @@ class TPortionsBucket: public TMoveOnly {
auto gChartsThis = StartModificationGuard();
if (NextBorder && MainPortion) {
AFL_VERIFY(portion->CrossPKWith(MainPortion->IndexKeyStart(), *NextBorder));
#ifndef NDEBUG
auto oldPortionInfo = GetOldestPortion(true);
auto youngPortionInfo = GetYoungestPortion(true);
AFL_VERIFY(oldPortionInfo && youngPortionInfo);
AFL_DEBUG(NKikimrServices::TX_COLUMNSHARD)
("event", "other_not_final")("delta", youngPortionInfo->RecordSnapshotMax().GetPlanStep() - oldPortionInfo->RecordSnapshotMax().GetPlanStep())
("main", MainPortion->DebugString(true))
("current", portion->DebugString(true))
("oldest", oldPortionInfo->DebugString(true))("young", youngPortionInfo->DebugString(true))
("bucket_from", MainPortion->IndexKeyStart().DebugString())("bucket_to", NextBorder->DebugString());
("event", "other_not_final")("delta", youngPortionInfo->RecordSnapshotMax().GetPlanStep() - oldPortionInfo->RecordSnapshotMax().GetPlanStep())
("main", MainPortion->DebugString(true))("current", portion->DebugString(true))("oldest", oldPortionInfo->DebugString(true))
("young", youngPortionInfo->DebugString(true))("bucket_from", MainPortion->IndexKeyStart().DebugString())("bucket_to", NextBorder->DebugString());
#endif
}
Others.Add(portion, now);
}
Expand All @@ -876,8 +882,11 @@ class TPortionsBucket: public TMoveOnly {
}

void Actualize(const TInstant currentInstant) {
if (currentInstant < NextActualizeInstant) {
return;
}
auto gChartsThis = StartModificationGuard();
Others.Actualize(currentInstant);
NextActualizeInstant = Others.Actualize(currentInstant);
RebuildOptimizedFeature(currentInstant);
}

Expand Down
Loading