@@ -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 ();
@@ -265,8 +265,9 @@ namespace NActors {
265
265
266
266
if (mailbox->IsEmpty ()) // was not-free and become free, we must reclaim mailbox
267
267
reclaimAsFree = true ;
268
-
269
- NHPTimer::STime elapsed = Ctx.AddEventProcessingStats (hpprev, hpnow, activityType, CurrentActorScheduledEventsCounter);
268
+
269
+ Ctx.AddElapsedCycles (activityType, hpnow - hpprev);
270
+ NHPTimer::STime elapsed = Ctx.AddEventProcessingStats (eventStart, hpnow, activityType, CurrentActorScheduledEventsCounter);
270
271
if (elapsed > 1000000 ) {
271
272
LwTraceSlowEvent (ev.Get (), evTypeForTracing, actorType, Ctx.PoolId , CurrentRecipient, NHPTimer::GetSeconds (elapsed) * 1000.0 );
272
273
}
@@ -286,9 +287,10 @@ namespace NActors {
286
287
Ctx.IncrementNonDeliveredEvents ();
287
288
}
288
289
hpnow = GetCycleCountFast ();
289
- hpprev = TlsThreadContext->StartOfElapsingTime . exchange (hpnow, std::memory_order_acq_rel );
290
+ hpprev = TlsThreadContext->UpdateStartOfElapsingTime (hpnow);
290
291
Ctx.AddElapsedCycles (ActorSystemIndex, hpnow - hpprev);
291
292
}
293
+ eventStart = hpnow;
292
294
293
295
if (TlsThreadContext->CapturedType == ESendingType::Tail) {
294
296
AtomicStore (&mailbox->ScheduleMoment , hpnow);
@@ -777,7 +779,7 @@ namespace NActors {
777
779
void TGenericExecutorThread::GetCurrentStats (TExecutorThreadStats& statsCopy) const {
778
780
NHPTimer::STime hpnow = GetCycleCountFast ();
779
781
ui64 activityType = TlsThreadCtx.ElapsingActorActivity .load (std::memory_order_acquire);
780
- NHPTimer::STime hpprev = TlsThreadCtx.StartOfElapsingTime . exchange (hpnow, std::memory_order_acq_rel );
782
+ NHPTimer::STime hpprev = TlsThreadCtx.UpdateStartOfElapsingTime (hpnow);
781
783
if (activityType == Max<ui64>()) {
782
784
Ctx.AddParkedCycles (hpnow - hpprev);
783
785
} else {
@@ -789,7 +791,7 @@ namespace NActors {
789
791
void TGenericExecutorThread::GetSharedStats (i16 poolId, TExecutorThreadStats &statsCopy) const {
790
792
NHPTimer::STime hpnow = GetCycleCountFast ();
791
793
ui64 activityType = TlsThreadCtx.ElapsingActorActivity .load (std::memory_order_acquire);
792
- NHPTimer::STime hpprev = TlsThreadCtx.StartOfElapsingTime . exchange (hpnow, std::memory_order_acq_rel );
794
+ NHPTimer::STime hpprev = TlsThreadCtx.UpdateStartOfElapsingTime (hpnow);
793
795
if (activityType == Max<ui64>()) {
794
796
Ctx.AddParkedCycles (hpnow - hpprev);
795
797
} else {
0 commit comments