@@ -199,16 +199,16 @@ namespace NActors {
199
199
bool firstEvent = true ;
200
200
bool preempted = false ;
201
201
bool wasWorking = false ;
202
- NHPTimer::STime hpnow = Ctx.HPStart ;
203
- NHPTimer::STime hpprev = TlsThreadContext->StartOfElapsingTime . exchange (hpnow, std::memory_order_acq_rel );
202
+ NHPTimer::STime hpnow = Ctx.HPStart ;
203
+ NHPTimer::STime hpprev = TlsThreadContext->UpdateStartOfElapsingTime (hpnow);
204
204
Ctx.AddElapsedCycles (ActorSystemIndex, hpnow - hpprev);
205
- hpprev = Ctx.HPStart ;
205
+ NHPTimer::STime eventStart = Ctx.HPStart ;
206
206
207
207
for (; Ctx.ExecutedEvents < Ctx.EventsPerMailbox ; ++Ctx.ExecutedEvents ) {
208
208
if (TAutoPtr<IEventHandle> evExt = mailbox->Pop ()) {
209
209
mailbox->ProcessEvents (mailbox);
210
210
recipient = evExt->GetRecipientRewrite ();
211
- TActorContext ctx (*mailbox, *this , hpprev , recipient);
211
+ TActorContext ctx (*mailbox, *this , eventStart , recipient);
212
212
TlsActivationContext = &ctx; // ensure dtor (if any) is called within actor system
213
213
// move for destruct before ctx;
214
214
auto ev = std::move (evExt);
@@ -250,7 +250,7 @@ namespace NActors {
250
250
actor->Receive (ev);
251
251
252
252
hpnow = GetCycleCountFast ();
253
- hpprev = TlsThreadContext->StartOfElapsingTime . exchange (hpnow, std::memory_order_acq_rel );
253
+ hpprev = TlsThreadContext->UpdateStartOfElapsingTime (hpnow);
254
254
255
255
mailbox->ProcessEvents (mailbox);
256
256
actor->OnDequeueEvent ();
@@ -266,7 +266,10 @@ namespace NActors {
266
266
if (mailbox->IsEmpty ()) // was not-free and become free, we must reclaim mailbox
267
267
reclaimAsFree = true ;
268
268
269
- NHPTimer::STime elapsed = Ctx.AddEventProcessingStats (hpprev, hpnow, activityType, CurrentActorScheduledEventsCounter);
269
+
270
+ Ctx.AddElapsedCycles (activityType, hpnow - hpprev);
271
+ Ctx.AddEventProcessingStats (eventStart, hpnow, activityType, CurrentActorScheduledEventsCounter);
272
+ NHPTimer::STime elapsed = hpnow - eventStart;
270
273
if (elapsed > 1000000 ) {
271
274
LwTraceSlowEvent (ev.Get (), evTypeForTracing, actorType, Ctx.PoolId , CurrentRecipient, NHPTimer::GetSeconds (elapsed) * 1000.0 );
272
275
}
@@ -286,9 +289,10 @@ namespace NActors {
286
289
Ctx.IncrementNonDeliveredEvents ();
287
290
}
288
291
hpnow = GetCycleCountFast ();
289
- hpprev = TlsThreadContext->StartOfElapsingTime . exchange (hpnow, std::memory_order_acq_rel );
292
+ hpprev = TlsThreadContext->UpdateStartOfElapsingTime (hpnow);
290
293
Ctx.AddElapsedCycles (ActorSystemIndex, hpnow - hpprev);
291
294
}
295
+ eventStart = hpnow;
292
296
293
297
if (TlsThreadContext->CapturedType == ESendingType::Tail) {
294
298
AtomicStore (&mailbox->ScheduleMoment , hpnow);
@@ -777,7 +781,7 @@ namespace NActors {
777
781
void TGenericExecutorThread::GetCurrentStats (TExecutorThreadStats& statsCopy) const {
778
782
NHPTimer::STime hpnow = GetCycleCountFast ();
779
783
ui64 activityType = TlsThreadCtx.ElapsingActorActivity .load (std::memory_order_acquire);
780
- NHPTimer::STime hpprev = TlsThreadCtx.StartOfElapsingTime . exchange (hpnow, std::memory_order_acq_rel );
784
+ NHPTimer::STime hpprev = TlsThreadCtx.UpdateStartOfElapsingTime (hpnow);
781
785
if (activityType == Max<ui64>()) {
782
786
Ctx.AddParkedCycles (hpnow - hpprev);
783
787
} else {
@@ -789,7 +793,7 @@ namespace NActors {
789
793
void TGenericExecutorThread::GetSharedStats (i16 poolId, TExecutorThreadStats &statsCopy) const {
790
794
NHPTimer::STime hpnow = GetCycleCountFast ();
791
795
ui64 activityType = TlsThreadCtx.ElapsingActorActivity .load (std::memory_order_acquire);
792
- NHPTimer::STime hpprev = TlsThreadCtx.StartOfElapsingTime . exchange (hpnow, std::memory_order_acq_rel );
796
+ NHPTimer::STime hpprev = TlsThreadCtx.UpdateStartOfElapsingTime (hpnow);
793
797
if (activityType == Max<ui64>()) {
794
798
Ctx.AddParkedCycles (hpnow - hpprev);
795
799
} else {
0 commit comments