Skip to content

Commit 2d8b5e2

Browse files
Merge 4118243 into 99d530f
2 parents 99d530f + 4118243 commit 2d8b5e2

File tree

11 files changed

+100
-45
lines changed

11 files changed

+100
-45
lines changed

ydb/core/tx/columnshard/data_accessor/manager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
#include <ydb/core/tx/columnshard/hooks/abstract/abstract.h>
44

5+
#include <ydb/library/accessor/positive_integer.h>
6+
57
namespace NKikimr::NOlap::NDataAccessorControl {
68

79
void TLocalManager::DrainQueue() {
810
std::optional<ui64> lastPathId;
911
IGranuleDataAccessor* lastDataAccessor = nullptr;
10-
ui32 countToFlight = 0;
12+
TPositiveControlInteger countToFlight;
1113
while (PortionsAskInFlight + countToFlight < NYDBTest::TControllers::GetColumnShardController()->GetLimitForPortionsMetadataAsk() &&
1214
PortionsAsk.size()) {
1315
THashMap<ui64, std::vector<TPortionInfo::TConstPtr>> portionsToAsk;
@@ -63,7 +65,6 @@ void TLocalManager::DrainQueue() {
6365
}
6466
}
6567
RequestsByPortion.erase(it);
66-
AFL_VERIFY(countToFlight);
6768
--countToFlight;
6869
}
6970
if (dataAnalyzed.GetPortionsToAsk().size()) {
@@ -72,7 +73,7 @@ void TLocalManager::DrainQueue() {
7273
}
7374
}
7475
}
75-
PortionsAskInFlight += countToFlight;
76+
PortionsAskInFlight.Add(countToFlight);
7677
Counters.FetchingCount->Set(PortionsAskInFlight);
7778
Counters.QueueSize->Set(PortionsAsk.size());
7879
}
@@ -119,7 +120,6 @@ void TLocalManager::DoAddPortion(const TPortionDataAccessor& accessor) {
119120
for (auto&& i : it->second) {
120121
i->AddAccessor(accessor);
121122
}
122-
AFL_VERIFY(PortionsAskInFlight);
123123
--PortionsAskInFlight;
124124
}
125125
RequestsByPortion.erase(it);

ydb/core/tx/columnshard/data_accessor/manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class TLocalManager: public IDataAccessorsManager {
134134
};
135135

136136
std::deque<TPortionToAsk> PortionsAsk;
137-
ui64 PortionsAskInFlight = 0;
137+
TPositiveControlInteger PortionsAskInFlight;
138138

139139
void DrainQueue();
140140

ydb/core/tx/columnshard/engines/changes/abstract/compaction_info.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
namespace NKikimr::NOlap {
66

77
bool TPlanCompactionInfo::Finish() {
8-
if (Count > 0) {
9-
return --Count == 0;
10-
} else {
11-
AFL_VERIFY(false);
12-
return false;
13-
}
8+
return --Count == 0;
149
}
1510

1611
} // namespace NKikimr::NOlap

ydb/core/tx/columnshard/engines/changes/abstract/compaction_info.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#pragma once
2+
#include <ydb/library/accessor/positive_integer.h>
3+
#include <ydb/library/actors/core/monotonic.h>
4+
25
#include <util/generic/string.h>
3-
#include <util/system/yassert.h>
46
#include <util/stream/output.h>
5-
#include <ydb/library/actors/core/monotonic.h>
7+
#include <util/system/yassert.h>
8+
69
#include <memory>
710

811
namespace NKikimr::NOlap {
@@ -12,7 +15,7 @@ class TPlanCompactionInfo {
1215
private:
1316
ui64 PathId = 0;
1417
TMonotonic StartTime = TMonotonic::Now();
15-
ui32 Count = 0;
18+
TPositiveControlInteger Count;
1619

1720
public:
1821
void Start() {
@@ -28,12 +31,11 @@ class TPlanCompactionInfo {
2831

2932
TPlanCompactionInfo(const ui64 pathId)
3033
: PathId(pathId) {
31-
3234
}
3335

3436
ui64 GetPathId() const {
3537
return PathId;
3638
}
3739
};
3840

39-
}
41+
} // namespace NKikimr::NOlap

ydb/core/tx/columnshard/engines/storage/optimizer/lcbuckets/planner/abstract.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class TPortionsChain {
116116
class TCompactionTaskData {
117117
private:
118118
YDB_ACCESSOR_DEF(std::vector<TPortionInfo::TConstPtr>, Portions);
119-
const ui64 TargetCompactionLevel = 0;
119+
const TPositiveControlInteger TargetCompactionLevel;
120120
std::shared_ptr<NCompaction::TGeneralCompactColumnEngineChanges::IMemoryPredictor> Predictor =
121121
NCompaction::TGeneralCompactColumnEngineChanges::BuildMemoryPredictor();
122122
ui64 MemoryUsage = 0;
@@ -135,12 +135,7 @@ class TCompactionTaskData {
135135
public:
136136
ui64 GetTargetCompactionLevel() const {
137137
if (MemoryUsage > ((ui64)1 << 30)) {
138-
if (TargetCompactionLevel) {
139-
return TargetCompactionLevel - 1;
140-
} else {
141-
AFL_VERIFY(false);
142-
return 0;
143-
}
138+
return TargetCompactionLevel.GetDec();
144139
} else {
145140
return TargetCompactionLevel;
146141
}

ydb/core/tx/limiter/grouped_memory/usage/abstract.h

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <ydb/core/tx/limiter/grouped_memory/service/counters.h>
33

44
#include <ydb/library/accessor/accessor.h>
5+
#include <ydb/library/accessor/positive_integer.h>
56
#include <ydb/library/actors/core/actor.h>
67
#include <ydb/library/actors/core/actorid.h>
78
#include <ydb/library/actors/core/log.h>
@@ -75,23 +76,6 @@ class TAllocationGuard {
7576
~TAllocationGuard();
7677
};
7778

78-
class TPositiveControlInteger {
79-
private:
80-
ui64 Value = 0;
81-
82-
public:
83-
void Add(const ui64 value) {
84-
Value += value;
85-
}
86-
void Sub(const ui64 value) {
87-
AFL_VERIFY(value <= Value)("base", Value)("delta", value);
88-
Value -= value;
89-
}
90-
ui64 Val() const {
91-
return Value;
92-
}
93-
};
94-
9579
class TStageFeatures {
9680
private:
9781
YDB_READONLY_DEF(TString, Name);
@@ -130,9 +114,9 @@ class TStageFeatures {
130114
if (HardLimit < Usage.Val() + volume) {
131115
Counters->OnCannotAllocate();
132116
AFL_DEBUG(NKikimrServices::GROUPED_MEMORY_LIMITER)("name", Name)("event", "cannot_allocate")("limit", HardLimit)(
133-
"usage", Usage.Val())(
134-
"delta", volume);
135-
return TConclusionStatus::Fail(TStringBuilder() << Name << "::(limit:" << HardLimit << ";val:" << Usage.Val() << ";delta=" << volume << ");");
117+
"usage", Usage.Val())("delta", volume);
118+
return TConclusionStatus::Fail(
119+
TStringBuilder() << Name << "::(limit:" << HardLimit << ";val:" << Usage.Val() << ";delta=" << volume << ");");
136120
}
137121
Usage.Add(volume);
138122
AFL_DEBUG(NKikimrServices::GROUPED_MEMORY_LIMITER)("name", Name)("event", "allocate")("usage", Usage.Val())("delta", volume);

ydb/core/tx/tiering/manager.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ TTiersManager::TTierRefGuard::~TTierRefGuard() {
197197
if (Owner) {
198198
auto findTier = Owner->TierRefCount.FindPtr(TierName);
199199
AFL_VERIFY(findTier);
200-
AFL_VERIFY(*findTier);
201200
--*findTier;
202201
if (!*findTier) {
203202
AFL_VERIFY(Owner->TierRefCount.erase(TierName));

ydb/core/tx/tiering/manager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <ydb/core/tx/tiering/tier/object.h>
88

99
#include <ydb/public/sdk/cpp/client/ydb_types/s3_settings.h>
10+
#include <ydb/library/accessor/positive_integer.h>
1011
#include <ydb/services/metadata/secret/snapshot.h>
1112
#include <ydb/services/metadata/service.h>
1213

@@ -77,7 +78,7 @@ class TTiersManager: public ITiersManager {
7778
IActor* Actor = nullptr;
7879
TManagers Managers;
7980

80-
using TTierRefCount = THashMap<TString, ui64>;
81+
using TTierRefCount = THashMap<TString, TPositiveControlInteger>;
8182
using TTierRefsByPathId = THashMap<ui64, std::vector<TTierRefGuard>>;
8283
YDB_READONLY_DEF(TTierRefCount, TierRefCount);
8384
YDB_READONLY_DEF(TTierRefsByPathId, UsedTiers);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include "positive_integer.h"
2+
#include <ydb/library/actors/core/log.h>
3+
4+
namespace NKikimr {
5+
6+
TPositiveControlInteger::TPositiveControlInteger(const i64 value)
7+
: Value(value) {
8+
AFL_VERIFY(0 <= value);
9+
}
10+
11+
ui64 TPositiveControlInteger::Add(const ui64 value) {
12+
Value += value;
13+
return Value;
14+
}
15+
16+
ui64 TPositiveControlInteger::Sub(const ui64 value) {
17+
if (value <= Value) {
18+
Value -= value;
19+
} else {
20+
AFL_VERIFY(false)("base", Value)("delta", value);
21+
}
22+
return Value;
23+
}
24+
25+
ui64 TPositiveControlInteger::GetDec() const {
26+
if (Value) {
27+
return Value - 1;
28+
} else {
29+
AFL_VERIFY(false);
30+
}
31+
return 0;
32+
}
33+
34+
ui64 TPositiveControlInteger::Val() const {
35+
return Value;
36+
}
37+
38+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#pragma once
2+
#include <util/system/types.h>
3+
4+
namespace NKikimr {
5+
6+
class TPositiveControlInteger {
7+
private:
8+
ui64 Value = 0;
9+
public:
10+
TPositiveControlInteger() = default;
11+
TPositiveControlInteger(const ui64 value)
12+
: Value(value) {
13+
14+
}
15+
TPositiveControlInteger(const i64 value);
16+
ui64 Add(const ui64 value);
17+
ui64 Sub(const ui64 value);
18+
ui64 Inc() {
19+
return Add(1);
20+
}
21+
ui64 Dec() {
22+
return Sub(1);
23+
}
24+
ui64 GetDec() const;
25+
ui64 Val() const;
26+
bool operator!() const {
27+
return !Value;
28+
}
29+
operator ui64() const {
30+
return Value;
31+
}
32+
ui64 operator++() {
33+
return Inc();
34+
}
35+
ui64 operator--() {
36+
return Dec();
37+
}
38+
};
39+
40+
}

0 commit comments

Comments
 (0)