@@ -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);
@@ -547,7 +551,9 @@ namespace NActors {
547
551
TlsThreadCtx.WorkerCtx = &Ctx;
548
552
TlsThreadCtx.ActorSystemIndex = ActorSystemIndex;
549
553
TlsThreadCtx.ElapsingActorActivity = ActorSystemIndex;
550
- TlsThreadCtx.StartOfElapsingTime = GetCycleCountFast ();
554
+ NHPTimer::STime now = GetCycleCountFast ();
555
+ TlsThreadCtx.StartOfProcessingEventTS = now;
556
+ TlsThreadCtx.ActivationStartTS = now;
551
557
TlsThreadContext = &TlsThreadCtx;
552
558
if (ThreadName) {
553
559
::SetCurrentThreadName (ThreadName);
@@ -777,27 +783,31 @@ namespace NActors {
777
783
}
778
784
}
779
785
780
- void TGenericExecutorThread::GetCurrentStats (TExecutorThreadStats& statsCopy) const {
786
+ void TGenericExecutorThread::UpdateThreadStats () {
781
787
NHPTimer::STime hpnow = GetCycleCountFast ();
782
788
ui64 activityType = TlsThreadCtx.ElapsingActorActivity .load (std::memory_order_acquire);
783
- NHPTimer::STime hpprev = TlsThreadCtx.UpdateStartOfElapsingTime (hpnow);
789
+ NHPTimer::STime hpprev = TlsThreadCtx.UpdateStartOfProcessingEventTS (hpnow);
784
790
if (activityType == Max<ui64>()) {
785
791
Ctx.AddParkedCycles (hpnow - hpprev);
786
792
} else {
787
793
Ctx.AddElapsedCycles (activityType, hpnow - hpprev);
788
794
}
795
+ if (activityType != Max<ui64>()) {
796
+ NHPTimer::STime activationStart = TlsThreadCtx.ActivationStartTS .load (std::memory_order_acquire);
797
+ NHPTimer::STime passedTime = Max<i64>(hpnow - activationStart, 0 );
798
+ Ctx.SetCurrentActivationTime (activityType, Ts2Us (passedTime));
799
+ } else {
800
+ Ctx.SetCurrentActivationTime (0 , 0 );
801
+ }
802
+ }
803
+
804
+ void TGenericExecutorThread::GetCurrentStats (TExecutorThreadStats& statsCopy) {
805
+ UpdateThreadStats ();
789
806
Ctx.GetCurrentStats (statsCopy);
790
807
}
791
808
792
- void TGenericExecutorThread::GetSharedStats (i16 poolId, TExecutorThreadStats &statsCopy) const {
793
- NHPTimer::STime hpnow = GetCycleCountFast ();
794
- ui64 activityType = TlsThreadCtx.ElapsingActorActivity .load (std::memory_order_acquire);
795
- NHPTimer::STime hpprev = TlsThreadCtx.UpdateStartOfElapsingTime (hpnow);
796
- if (activityType == Max<ui64>()) {
797
- Ctx.AddParkedCycles (hpnow - hpprev);
798
- } else {
799
- Ctx.AddElapsedCycles (activityType, hpnow - hpprev);
800
- }
809
+ void TGenericExecutorThread::GetSharedStats (i16 poolId, TExecutorThreadStats &statsCopy) {
810
+ UpdateThreadStats ();
801
811
statsCopy = TExecutorThreadStats ();
802
812
statsCopy.Aggregate (SharedStats[poolId]);
803
813
}
0 commit comments