Skip to content

Commit be06910

Browse files
authored
fix elapsed microsec for first Event in Mailbox (#3810)
1 parent af0e0ec commit be06910

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ydb/library/actors/core/executor_thread.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ namespace NActors {
191191
Ctx.HPStart = GetCycleCountFast();
192192
Ctx.ExecutedEvents = 0;
193193
}
194-
NHPTimer::STime hpprev = Ctx.HPStart;
195194

196195
IActor* actor = nullptr;
197196
const std::type_info* actorType = nullptr;
@@ -200,10 +199,14 @@ namespace NActors {
200199
bool firstEvent = true;
201200
bool preempted = false;
202201
bool wasWorking = false;
202+
NHPTimer::STime hpnow = Ctx.HPStart;
203+
NHPTimer::STime hpprev = TlsThreadContext->StartOfElapsingTime.exchange(hpnow, std::memory_order_acq_rel);
204+
Ctx.AddElapsedCycles(ActorSystemIndex, hpnow - hpprev);
205+
hpprev = Ctx.HPStart;
206+
203207
for (; Ctx.ExecutedEvents < Ctx.EventsPerMailbox; ++Ctx.ExecutedEvents) {
204208
if (TAutoPtr<IEventHandle> evExt = mailbox->Pop()) {
205209
mailbox->ProcessEvents(mailbox);
206-
NHPTimer::STime hpnow;
207210
recipient = evExt->GetRecipientRewrite();
208211
TActorContext ctx(*mailbox, *this, hpprev, recipient);
209212
TlsActivationContext = &ctx; // ensure dtor (if any) is called within actor system

0 commit comments

Comments
 (0)