@@ -200,9 +200,10 @@ namespace NActors {
200
200
bool preempted = false ;
201
201
bool wasWorking = false ;
202
202
NHPTimer::STime hpnow = Ctx.HPStart ;
203
- NHPTimer::STime hpprev = TlsThreadContext->UpdateStartOfElapsingTime (hpnow);
203
+ NHPTimer::STime hpprev = TlsThreadContext->UpdateStartOfProcessingEventTS (hpnow);
204
204
Ctx.AddElapsedCycles (ActorSystemIndex, hpnow - hpprev);
205
205
NHPTimer::STime eventStart = Ctx.HPStart ;
206
+ TlsThreadContext->ActivationStartTS .store (Ctx.HPStart , std::memory_order_release);
206
207
207
208
for (; Ctx.ExecutedEvents < Ctx.EventsPerMailbox ; ++Ctx.ExecutedEvents ) {
208
209
if (TAutoPtr<IEventHandle> evExt = mailbox->Pop ()) {
@@ -250,7 +251,7 @@ namespace NActors {
250
251
actor->Receive (ev);
251
252
252
253
hpnow = GetCycleCountFast ();
253
- hpprev = TlsThreadContext->UpdateStartOfElapsingTime (hpnow);
254
+ hpprev = TlsThreadContext->UpdateStartOfProcessingEventTS (hpnow);
254
255
255
256
mailbox->ProcessEvents (mailbox);
256
257
actor->OnDequeueEvent ();
@@ -287,7 +288,7 @@ namespace NActors {
287
288
Ctx.IncrementNonDeliveredEvents ();
288
289
}
289
290
hpnow = GetCycleCountFast ();
290
- hpprev = TlsThreadContext->UpdateStartOfElapsingTime (hpnow);
291
+ hpprev = TlsThreadContext->UpdateStartOfProcessingEventTS (hpnow);
291
292
Ctx.AddElapsedCycles (ActorSystemIndex, hpnow - hpprev);
292
293
}
293
294
eventStart = hpnow;
@@ -371,6 +372,7 @@ namespace NActors {
371
372
break ; // empty queue, leave
372
373
}
373
374
}
375
+ TlsThreadContext->ActivationStartTS .store (GetCycleCountFast (), std::memory_order_release);
374
376
TlsThreadContext->ElapsingActorActivity .store (ActorSystemIndex, std::memory_order_release);
375
377
376
378
NProfiling::TMemoryTagScope::Reset (0 );
@@ -510,7 +512,9 @@ namespace NActors {
510
512
TlsThreadCtx.WorkerCtx = &Ctx;
511
513
TlsThreadCtx.ActorSystemIndex = ActorSystemIndex;
512
514
TlsThreadCtx.ElapsingActorActivity = ActorSystemIndex;
513
- TlsThreadCtx.StartOfElapsingTime = GetCycleCountFast ();
515
+ NHPTimer::STime now = GetCycleCountFast ();
516
+ TlsThreadCtx.StartOfProcessingEventTS = now;
517
+ TlsThreadCtx.ActivationStartTS = now;
514
518
TlsThreadContext = &TlsThreadCtx;
515
519
if (ThreadName) {
516
520
::SetCurrentThreadName (ThreadName);
@@ -546,7 +550,9 @@ namespace NActors {
546
550
TlsThreadCtx.WorkerCtx = &Ctx;
547
551
TlsThreadCtx.ActorSystemIndex = ActorSystemIndex;
548
552
TlsThreadCtx.ElapsingActorActivity = ActorSystemIndex;
549
- TlsThreadCtx.StartOfElapsingTime = GetCycleCountFast ();
553
+ NHPTimer::STime now = GetCycleCountFast ();
554
+ TlsThreadCtx.StartOfProcessingEventTS = now;
555
+ TlsThreadCtx.ActivationStartTS = now;
550
556
TlsThreadContext = &TlsThreadCtx;
551
557
if (ThreadName) {
552
558
::SetCurrentThreadName (ThreadName);
@@ -776,27 +782,31 @@ namespace NActors {
776
782
}
777
783
}
778
784
779
- void TGenericExecutorThread::GetCurrentStats (TExecutorThreadStats& statsCopy) const {
785
+ void TGenericExecutorThread::UpdateThreadStats () {
780
786
NHPTimer::STime hpnow = GetCycleCountFast ();
781
787
ui64 activityType = TlsThreadCtx.ElapsingActorActivity .load (std::memory_order_acquire);
782
- NHPTimer::STime hpprev = TlsThreadCtx.UpdateStartOfElapsingTime (hpnow);
788
+ NHPTimer::STime hpprev = TlsThreadCtx.UpdateStartOfProcessingEventTS (hpnow);
783
789
if (activityType == Max<ui64>()) {
784
790
Ctx.AddParkedCycles (hpnow - hpprev);
785
791
} else {
786
792
Ctx.AddElapsedCycles (activityType, hpnow - hpprev);
787
793
}
794
+ if (activityType != Max<ui64>()) {
795
+ NHPTimer::STime activationStart = TlsThreadCtx.ActivationStartTS .load (std::memory_order_acquire);
796
+ NHPTimer::STime passedTime = Max<i64>(hpnow - activationStart, 0 );
797
+ Ctx.SetCurrentActivationTime (activityType, Ts2Us (passedTime));
798
+ } else {
799
+ Ctx.SetCurrentActivationTime (0 , 0 );
800
+ }
801
+ }
802
+
803
+ void TGenericExecutorThread::GetCurrentStats (TExecutorThreadStats& statsCopy) {
804
+ UpdateThreadStats ();
788
805
Ctx.GetCurrentStats (statsCopy);
789
806
}
790
807
791
- void TGenericExecutorThread::GetSharedStats (i16 poolId, TExecutorThreadStats &statsCopy) const {
792
- NHPTimer::STime hpnow = GetCycleCountFast ();
793
- ui64 activityType = TlsThreadCtx.ElapsingActorActivity .load (std::memory_order_acquire);
794
- NHPTimer::STime hpprev = TlsThreadCtx.UpdateStartOfElapsingTime (hpnow);
795
- if (activityType == Max<ui64>()) {
796
- Ctx.AddParkedCycles (hpnow - hpprev);
797
- } else {
798
- Ctx.AddElapsedCycles (activityType, hpnow - hpprev);
799
- }
808
+ void TGenericExecutorThread::GetSharedStats (i16 poolId, TExecutorThreadStats &statsCopy) {
809
+ UpdateThreadStats ();
800
810
statsCopy = TExecutorThreadStats ();
801
811
statsCopy.Aggregate (SharedStats[poolId]);
802
812
}
0 commit comments