Skip to content

Commit 8879b1f

Browse files
committed
EXT-1551. Remove obsolete UsageByActivity sensor from ActorSystem (#26188)
1 parent 62843c1 commit 8879b1f

File tree

12 files changed

+431
-162
lines changed

12 files changed

+431
-162
lines changed

ydb/library/actors/core/actor.cpp

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -35,62 +35,6 @@ namespace NActors {
3535
return *this;
3636
}
3737

38-
template<i64 Increment>
39-
static void UpdateQueueSizeAndTimestamp(TActorUsageImpl<true>& impl, ui64 time) {
40-
ui64 usedTimeIncrement = 0;
41-
using T = TActorUsageImpl<true>;
42-
43-
for (;;) {
44-
uint64_t value = impl.QueueSizeAndTimestamp.load();
45-
ui64 count = value >> T::TimestampBits;
46-
47-
count += Increment;
48-
Y_ABORT_UNLESS((count & ~T::CountMask) == 0);
49-
50-
ui64 timestamp = value;
51-
if (Increment == 1 && count == 1) {
52-
timestamp = time;
53-
} else if (Increment == -1 && count == 0) {
54-
usedTimeIncrement = (static_cast<ui64>(time) - timestamp) & T::TimestampMask;
55-
timestamp = 0; // reset timestamp to some zero value
56-
}
57-
58-
const ui64 updated = (timestamp & T::TimestampMask) | (count << T::TimestampBits);
59-
if (impl.QueueSizeAndTimestamp.compare_exchange_weak(value, updated)) {
60-
break;
61-
}
62-
}
63-
64-
if (usedTimeIncrement && impl.LastUsageTimestamp <= time) {
65-
impl.UsedTime += usedTimeIncrement;
66-
}
67-
}
68-
69-
void TActorUsageImpl<true>::OnEnqueueEvent(ui64 time) {
70-
UpdateQueueSizeAndTimestamp<+1>(*this, time);
71-
}
72-
73-
void TActorUsageImpl<true>::OnDequeueEvent() {
74-
UpdateQueueSizeAndTimestamp<-1>(*this, GetCycleCountFast());
75-
}
76-
77-
double TActorUsageImpl<true>::GetUsage(ui64 time) {
78-
ui64 used = UsedTime.exchange(0);
79-
if (const ui64 value = QueueSizeAndTimestamp.load(); value >> TimestampBits) {
80-
used += (static_cast<ui64>(time) - value) & TimestampMask;
81-
}
82-
83-
Y_ABORT_UNLESS(LastUsageTimestamp <= time);
84-
ui64 passed = time - LastUsageTimestamp;
85-
LastUsageTimestamp = time;
86-
87-
if (!passed) {
88-
return 0;
89-
}
90-
91-
return (double)Min(passed, used) / passed;
92-
}
93-
9438
void IActor::Describe(IOutputStream &out) const noexcept {
9539
SelfActorId.Out(out);
9640
}

ydb/library/actors/core/actor.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -320,34 +320,9 @@ namespace NActors {
320320

321321
};
322322

323-
template<bool>
324-
struct TActorUsageImpl {
325-
void OnEnqueueEvent(ui64 /*time*/) {} // called asynchronously when event is put in the mailbox
326-
void OnDequeueEvent() {} // called when processed by Executor
327-
double GetUsage(ui64 /*time*/) { return 0; } // called from collector thread
328-
void DoActorInit() {}
329-
};
330-
331-
template<>
332-
struct TActorUsageImpl<true> {
333-
static constexpr int TimestampBits = 40;
334-
static constexpr int CountBits = 24;
335-
static constexpr ui64 TimestampMask = ((ui64)1 << TimestampBits) - 1;
336-
static constexpr ui64 CountMask = ((ui64)1 << CountBits) - 1;
337-
338-
std::atomic_uint64_t QueueSizeAndTimestamp = 0;
339-
std::atomic_uint64_t UsedTime = 0; // how much time did we consume since last GetUsage() call
340-
ui64 LastUsageTimestamp = 0; // when GetUsage() was called the last time
341-
342-
void OnEnqueueEvent(ui64 time);
343-
void OnDequeueEvent();
344-
double GetUsage(ui64 time);
345-
void DoActorInit() { LastUsageTimestamp = GetCycleCountFast(); }
346-
};
347323

348324
class IActor
349325
: protected IActorOps
350-
, public TActorUsageImpl<ActorLibCollectUsageStats>
351326
{
352327
private:
353328
TActorIdentity SelfActorId;

ydb/library/actors/core/defs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
// event processing time histograms
1313
#define ACTORSLIB_COLLECT_EXEC_STATS
1414

15-
static constexpr bool ActorLibCollectUsageStats = false;
16-
1715
namespace NActors {
1816
using TPoolId = ui8;
1917
using TPoolsMask = ui64;

ydb/library/actors/core/executor_pool_base.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ namespace NActors {
1212

1313
void DoActorInit(TActorSystem* sys, IActor* actor, const TActorId& self, const TActorId& owner) {
1414
actor->SelfActorId = self;
15-
actor->DoActorInit();
1615
actor->Registered(sys, owner);
1716
}
1817

@@ -34,17 +33,6 @@ namespace NActors {
3433

3534
const TMonotonic now = ActorSystem->Monotonic();
3635

37-
for (auto& u : stats.UsageByActivity) {
38-
u.fill(0);
39-
}
40-
41-
auto accountUsage = [&](ui32 activityType, double usage) {
42-
Y_ABORT_UNLESS(0 <= usage);
43-
Y_ABORT_UNLESS(usage <= 1);
44-
int bin = Min<int>(9, usage * 10);
45-
++stats.UsageByActivity[activityType][bin];
46-
};
47-
4836
std::fill(stats.StuckActorsByActivity.begin(), stats.StuckActorsByActivity.end(), 0);
4937

5038
with_lock (StuckObserverMutex) {
@@ -55,12 +43,7 @@ namespace NActors {
5543
if (delta > TDuration::Seconds(30)) {
5644
++stats.StuckActorsByActivity[actor->GetActivityType()];
5745
}
58-
accountUsage(actor->GetActivityType(), actor->GetUsage(GetCycleCountFast()));
59-
}
60-
for (const auto& [activityType, usage] : DeadActorsUsage) {
61-
accountUsage(activityType, usage);
6246
}
63-
DeadActorsUsage.clear();
6447
}
6548
}
6649
#endif

ydb/library/actors/core/executor_pool_base.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ namespace NActors {
2626
// Stuck actor monitoring
2727
TMutex StuckObserverMutex;
2828
std::vector<IActor*> Actors;
29-
mutable std::vector<std::tuple<ui32, double>> DeadActorsUsage;
3029
friend class TGenericExecutorThread;
3130
friend class TSharedExecutorThread;
3231
void RecalculateStuckActors(TExecutorThreadStats& stats) const;

ydb/library/actors/core/executor_thread.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ namespace NActors {
122122
actorPtr = pool->Actors.back();
123123
actorPtr->StuckIndex = i;
124124
pool->Actors.pop_back();
125-
pool->DeadActorsUsage.emplace_back(actor->GetActivityType(), actor->GetUsage(GetCycleCountFast()));
126125
}
127126
}
128127
}
@@ -207,7 +206,6 @@ namespace NActors {
207206

208207
for (; Ctx.ExecutedEvents < Ctx.EventsPerMailbox; ++Ctx.ExecutedEvents) {
209208
if (TAutoPtr<IEventHandle> evExt = mailbox->Pop()) {
210-
mailbox->ProcessEvents(mailbox);
211209
recipient = evExt->GetRecipientRewrite();
212210
TActorContext ctx(*mailbox, *this, eventStart, recipient);
213211
TlsActivationContext = &ctx; // ensure dtor (if any) is called within actor system
@@ -253,14 +251,10 @@ namespace NActors {
253251
hpnow = GetCycleCountFast();
254252
hpprev = TlsThreadContext->UpdateStartOfProcessingEventTS(hpnow);
255253

256-
mailbox->ProcessEvents(mailbox);
257-
actor->OnDequeueEvent();
258-
259254
size_t dyingActorsCnt = DyingActors.size();
260255
Ctx.UpdateActorsStats(dyingActorsCnt);
261256
if (dyingActorsCnt) {
262257
DropUnregistered();
263-
mailbox->ProcessEvents(mailbox);
264258
actor = nullptr;
265259
}
266260

ydb/library/actors/core/mailbox.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ namespace NActors {
180180
switch (x->MailboxType) {
181181
case TMailboxType::Simple: {
182182
TSimpleMailbox* const mailbox = TSimpleMailbox::Get(lineHint, x);
183-
mailbox->Push(recipient.LocalId());
184183
#if (!defined(_tsan_enabled_))
185184
Y_DEBUG_ABORT_UNLESS(mailbox->Type == (ui32)x->MailboxType);
186185
#endif
@@ -205,7 +204,6 @@ namespace NActors {
205204
return false;
206205

207206
TRevolvingMailbox* const mailbox = TRevolvingMailbox::Get(lineHint, x);
208-
mailbox->Push(recipient.LocalId());
209207
#if (!defined(_tsan_enabled_))
210208
Y_DEBUG_ABORT_UNLESS(mailbox->Type == (ui32)x->MailboxType);
211209
#endif
@@ -218,7 +216,6 @@ namespace NActors {
218216
return true;
219217
case TMailboxType::HTSwap: {
220218
THTSwapMailbox* const mailbox = THTSwapMailbox::Get(lineHint, x);
221-
mailbox->Push(recipient.LocalId());
222219
#if (!defined(_tsan_enabled_))
223220
Y_DEBUG_ABORT_UNLESS(mailbox->Type == (ui32)x->MailboxType);
224221
#endif
@@ -234,7 +231,6 @@ namespace NActors {
234231
return false;
235232

236233
TReadAsFilledMailbox* const mailbox = TReadAsFilledMailbox::Get(lineHint, x);
237-
mailbox->Push(recipient.LocalId());
238234
#if (!defined(_tsan_enabled_))
239235
Y_DEBUG_ABORT_UNLESS(mailbox->Type == (ui32)x->MailboxType);
240236
#endif
@@ -250,7 +246,6 @@ namespace NActors {
250246
return false;
251247

252248
TTinyReadAsFilledMailbox* const mailbox = TTinyReadAsFilledMailbox::Get(lineHint, x);
253-
mailbox->Push(recipient.LocalId());
254249
#if (!defined(_tsan_enabled_))
255250
Y_DEBUG_ABORT_UNLESS(mailbox->Type == (ui32)x->MailboxType);
256251
#endif
@@ -435,24 +430,6 @@ namespace NActors {
435430
}
436431
}
437432

438-
TMailboxUsageImpl<true>::~TMailboxUsageImpl() {
439-
while (auto *e = PendingEventQueue.Pop()) {
440-
delete e;
441-
}
442-
}
443-
444-
void TMailboxUsageImpl<true>::Push(ui64 localId) {
445-
PendingEventQueue.Push(new TPendingEvent{localId, GetCycleCountFast()});
446-
}
447-
448-
void TMailboxUsageImpl<true>::ProcessEvents(TMailboxHeader *mailbox) {
449-
while (std::unique_ptr<TPendingEvent> e{PendingEventQueue.Pop()}) {
450-
if (IActor *actor = mailbox->FindActor(e->LocalId)) {
451-
actor->OnEnqueueEvent(e->Timestamp);
452-
}
453-
}
454-
}
455-
456433
TMailboxTable::TSimpleMailbox::TSimpleMailbox()
457434
: TMailboxHeader(TMailboxType::Simple)
458435
, ScheduleMoment(0)

ydb/library/actors/core/mailbox.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,7 @@ namespace NActors {
3232
ui64 ElapsedCycles = 0;
3333
};
3434

35-
template<bool>
36-
struct TMailboxUsageImpl {
37-
void Push(ui64 /*localId*/) {}
38-
void ProcessEvents(TMailboxHeader* /*mailbox*/) {}
39-
};
40-
41-
template<>
42-
struct TMailboxUsageImpl<true> {
43-
struct TPendingEvent {
44-
ui64 LocalId;
45-
ui64 Timestamp;
46-
};
47-
NThreading::TReadAsFilledQueue<TPendingEvent> PendingEventQueue;
48-
49-
~TMailboxUsageImpl();
50-
void Push(ui64 localId);
51-
void ProcessEvents(TMailboxHeader *mailbox);
52-
};
53-
5435
struct TMailboxHeader
55-
: TMailboxUsageImpl<ActorLibCollectUsageStats>
5636
{
5737
struct TMailboxActorPack {
5838
enum EType {

ydb/library/actors/core/mon_stats.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ namespace NActors {
3838
, ActorsAliveByActivity(TLocalProcessKeyStateIndexLimiter::GetMaxKeysCount())
3939
, ScheduledEventsByActivity(TLocalProcessKeyStateIndexLimiter::GetMaxKeysCount())
4040
, StuckActorsByActivity(TLocalProcessKeyStateIndexLimiter::GetMaxKeysCount())
41-
, UsageByActivity(TLocalProcessKeyStateIndexLimiter::GetMaxKeysCount())
4241
{}
4342

4443
namespace {
@@ -95,15 +94,6 @@ namespace NActors {
9594
AggregatedCurrentActivationTime.insert(AggregatedCurrentActivationTime.end(), other.AggregatedCurrentActivationTime.begin(), other.AggregatedCurrentActivationTime.end());
9695
}
9796

98-
if (UsageByActivity.size() < other.UsageByActivity.size()) {
99-
UsageByActivity.resize(other.UsageByActivity.size());
100-
}
101-
for (size_t i = 0; i < UsageByActivity.size(); ++i) {
102-
for (size_t j = 0; j < 10; ++j) {
103-
UsageByActivity[i][j] += RelaxedLoad(&other.UsageByActivity[i][j]);
104-
}
105-
}
106-
10797
RelaxedStore(
10898
&PoolActorRegistrations,
10999
std::max(RelaxedLoad(&PoolActorRegistrations), RelaxedLoad(&other.PoolActorRegistrations)));
@@ -119,4 +109,4 @@ namespace NActors {
119109
return ActorsAliveByActivity.size();
120110
}
121111

122-
}
112+
}

ydb/library/actors/core/mon_stats.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ namespace NActors {
113113
TVector<ui64> ScheduledEventsByActivity;
114114
TVector<ui64> StuckActorsByActivity;
115115
TVector<TActivationTime> AggregatedCurrentActivationTime;
116-
TVector<std::array<ui64, 10>> UsageByActivity;
117116
ui64 PoolActorRegistrations = 0;
118117
ui64 PoolDestroyedActors = 0;
119118
ui64 PoolAllocatedMailboxes = 0;

0 commit comments

Comments
 (0)