8
8
9
9
namespace NActors {
10
10
struct TLogHistogram : public NMonitoring ::IHistogramSnapshot {
11
- TLogHistogram () {
12
- memset (Buckets, 0 , sizeof (Buckets));
13
- }
11
+ TLogHistogram ();
14
12
15
13
inline void Add (ui64 val, ui64 inc = 1 ) {
16
14
size_t ind = 0 ;
@@ -29,31 +27,14 @@ namespace NActors {
29
27
RelaxedStore (&Buckets[ind], RelaxedLoad (&Buckets[ind]) + inc);
30
28
}
31
29
32
- void Aggregate (const TLogHistogram& other) {
33
- const ui64 inc = RelaxedLoad (&other.TotalSamples );
34
- RelaxedStore (&TotalSamples, RelaxedLoad (&TotalSamples) + inc);
35
- for (size_t i = 0 ; i < Y_ARRAY_SIZE (Buckets); ++i) {
36
- Buckets[i] += RelaxedLoad (&other.Buckets [i]);
37
- }
38
- }
30
+ void Aggregate (const TLogHistogram& other);
39
31
40
32
// IHistogramSnapshot
41
- ui32 Count () const override {
42
- return Y_ARRAY_SIZE (Buckets);
43
- }
33
+ ui32 Count () const override ;
44
34
45
- NMonitoring::TBucketBound UpperBound (ui32 index) const override {
46
- Y_ASSERT (index < Y_ARRAY_SIZE (Buckets));
47
- if (index == 0 ) {
48
- return 1 ;
49
- }
50
- return NMonitoring::TBucketBound (1ull << (index - 1 )) * 2.0 ;
51
- }
35
+ NMonitoring::TBucketBound UpperBound (ui32 index) const override ;
52
36
53
- NMonitoring::TBucketValue Value (ui32 index) const override {
54
- Y_ASSERT (index < Y_ARRAY_SIZE (Buckets));
55
- return Buckets[index];
56
- }
37
+ NMonitoring::TBucketValue Value (ui32 index) const override ;
57
38
58
39
ui64 TotalSamples = 0 ;
59
40
ui64 Buckets[65 ];
@@ -126,85 +107,11 @@ namespace NActors {
126
107
ui64 MailboxPushedOutByEventCount = 0 ;
127
108
ui64 NotEnoughCpuExecutions = 0 ;
128
109
129
- TExecutorThreadStats () // must be not empty as 0 used as default
130
- : ElapsedTicksByActivity(TLocalProcessKeyStateIndexLimiter::GetMaxKeysCount())
131
- , ReceivedEventsByActivity(TLocalProcessKeyStateIndexLimiter::GetMaxKeysCount())
132
- , ActorsAliveByActivity(TLocalProcessKeyStateIndexLimiter::GetMaxKeysCount())
133
- , ScheduledEventsByActivity(TLocalProcessKeyStateIndexLimiter::GetMaxKeysCount())
134
- , StuckActorsByActivity(TLocalProcessKeyStateIndexLimiter::GetMaxKeysCount())
135
- , UsageByActivity(TLocalProcessKeyStateIndexLimiter::GetMaxKeysCount())
136
- {}
137
-
138
- template <typename T>
139
- static void AggregateOne (TVector<T>& self, const TVector<T>& other) {
140
- const size_t selfSize = self.size ();
141
- const size_t otherSize = other.size ();
142
- if (selfSize < otherSize)
143
- self.resize (otherSize);
144
- for (size_t at = 0 ; at < otherSize; ++at)
145
- self[at] += RelaxedLoad (&other[at]);
146
- }
110
+ TExecutorThreadStats ();
147
111
148
- void Aggregate (const TExecutorThreadStats& other) {
149
- SentEvents += RelaxedLoad (&other.SentEvents );
150
- ReceivedEvents += RelaxedLoad (&other.ReceivedEvents );
151
- PreemptedEvents += RelaxedLoad (&other.PreemptedEvents );
152
- NonDeliveredEvents += RelaxedLoad (&other.NonDeliveredEvents );
153
- EmptyMailboxActivation += RelaxedLoad (&other.EmptyMailboxActivation );
154
- CpuUs += RelaxedLoad (&other.CpuUs );
155
- SafeElapsedTicks += RelaxedLoad (&other.SafeElapsedTicks );
156
- RelaxedStore (
157
- &WorstActivationTimeUs,
158
- std::max (RelaxedLoad (&WorstActivationTimeUs), RelaxedLoad (&other.WorstActivationTimeUs )));
159
- ElapsedTicks += RelaxedLoad (&other.ElapsedTicks );
160
- ParkedTicks += RelaxedLoad (&other.ParkedTicks );
161
- BlockedTicks += RelaxedLoad (&other.BlockedTicks );
162
- MailboxPushedOutByTailSending += RelaxedLoad (&other.MailboxPushedOutByTailSending );
163
- MailboxPushedOutBySoftPreemption += RelaxedLoad (&other.MailboxPushedOutBySoftPreemption );
164
- MailboxPushedOutByTime += RelaxedLoad (&other.MailboxPushedOutByTime );
165
- MailboxPushedOutByEventCount += RelaxedLoad (&other.MailboxPushedOutByEventCount );
166
- NotEnoughCpuExecutions += RelaxedLoad (&other.NotEnoughCpuExecutions );
167
-
168
- ActivationTimeHistogram.Aggregate (other.ActivationTimeHistogram );
169
- EventDeliveryTimeHistogram.Aggregate (other.EventDeliveryTimeHistogram );
170
- EventProcessingCountHistogram.Aggregate (other.EventProcessingCountHistogram );
171
- EventProcessingTimeHistogram.Aggregate (other.EventProcessingTimeHistogram );
172
-
173
- AggregateOne (ElapsedTicksByActivity, other.ElapsedTicksByActivity );
174
- AggregateOne (ReceivedEventsByActivity, other.ReceivedEventsByActivity );
175
- AggregateOne (ActorsAliveByActivity, other.ActorsAliveByActivity );
176
- AggregateOne (ScheduledEventsByActivity, other.ScheduledEventsByActivity );
177
- AggregateOne (StuckActorsByActivity, other.StuckActorsByActivity );
178
- if (other.CurrentActivationTime .TimeUs ) {
179
- AggregatedCurrentActivationTime.push_back (other.CurrentActivationTime );
180
- }
181
- if (other.AggregatedCurrentActivationTime .size ()) {
182
- AggregatedCurrentActivationTime.insert (AggregatedCurrentActivationTime.end (), other.AggregatedCurrentActivationTime .begin (), other.AggregatedCurrentActivationTime .end ());
183
- }
184
-
185
- if (UsageByActivity.size () < other.UsageByActivity .size ()) {
186
- UsageByActivity.resize (other.UsageByActivity .size ());
187
- }
188
- for (size_t i = 0 ; i < UsageByActivity.size (); ++i) {
189
- for (size_t j = 0 ; j < 10 ; ++j) {
190
- UsageByActivity[i][j] += RelaxedLoad (&other.UsageByActivity [i][j]);
191
- }
192
- }
193
-
194
- RelaxedStore (
195
- &PoolActorRegistrations,
196
- std::max (RelaxedLoad (&PoolActorRegistrations), RelaxedLoad (&other.PoolActorRegistrations )));
197
- RelaxedStore (
198
- &PoolDestroyedActors,
199
- std::max (RelaxedLoad (&PoolDestroyedActors), RelaxedLoad (&other.PoolDestroyedActors )));
200
- RelaxedStore (
201
- &PoolAllocatedMailboxes,
202
- std::max (RelaxedLoad (&PoolAllocatedMailboxes), RelaxedLoad (&other.PoolAllocatedMailboxes )));
203
- }
112
+ void Aggregate (const TExecutorThreadStats& other);
204
113
205
- size_t MaxActivityType () const {
206
- return ActorsAliveByActivity.size ();
207
- }
114
+ size_t MaxActivityType () const ;
208
115
};
209
116
210
117
}
0 commit comments