@@ -26,9 +26,10 @@ namespace Memory
26
26
hostInterface (hostInterface),
27
27
lastPassStats (nullptr ),
28
28
recyclerStartTime (Js::Tick::Now()),
29
- abortTelemetryCapture (false )
29
+ abortTelemetryCapture (false ),
30
+ inPassActiveState (false ),
31
+ recycler (recycler)
30
32
{
31
- this ->recycler = recycler;
32
33
mainThreadID = ::GetCurrentThreadId ();
33
34
}
34
35
@@ -52,11 +53,15 @@ namespace Memory
52
53
return this ->recycler ->IsConcurrentEnabled ();
53
54
}
54
55
55
- bool RecyclerTelemetryInfo::ShouldCaptureRecyclerTelemetry () const
56
+ bool RecyclerTelemetryInfo::ShouldStartTelemetryCapture () const
56
57
{
57
- return this ->hostInterface != nullptr && this ->abortTelemetryCapture == false ;
58
+ return
59
+ this ->hostInterface != nullptr &&
60
+ this ->abortTelemetryCapture == false &&
61
+ this ->hostInterface ->IsTelemetryProviderEnabled ();
58
62
}
59
63
64
+
60
65
void RecyclerTelemetryInfo::FillInSizeData (IdleDecommitPageAllocator* allocator, AllocatorSizes* sizes) const
61
66
{
62
67
sizes->committedBytes = allocator->GetCommittedBytes ();
@@ -67,86 +72,86 @@ namespace Memory
67
72
68
73
void RecyclerTelemetryInfo::StartPass ()
69
74
{
70
- Js::Tick start = Js::Tick::Now () ;
71
- if (! this ->ShouldCaptureRecyclerTelemetry ())
75
+ this -> inPassActiveState = false ;
76
+ if (this ->ShouldStartTelemetryCapture ())
72
77
{
73
- return ;
74
- }
75
-
76
- AssertOnValidThread (this , RecyclerTelemetryInfo::StartPass);
78
+ Js::Tick start = Js::Tick::Now ();
79
+ AssertOnValidThread (this , RecyclerTelemetryInfo::StartPass);
77
80
#if DBG
78
- // validate state of existing GC pass stats structs
79
- uint16 count = 0 ;
80
- if (this ->lastPassStats != nullptr )
81
- {
82
- RecyclerTelemetryGCPassStats* head = this ->lastPassStats ->next ;
83
- RecyclerTelemetryGCPassStats* curr = head;
84
- do
81
+ // validate state of existing GC pass stats structs
82
+ uint16 count = 0 ;
83
+ if (this ->lastPassStats != nullptr )
85
84
{
86
- AssertMsg (curr->isGCPassActive == false , " unexpected value for isGCPassActive" );
87
- count++;
88
- curr = curr->next ;
89
- } while (curr != head);
90
- }
91
- AssertMsg (count == this ->passCount , " RecyclerTelemetryInfo::StartPass() - mismatch between passCount and count." );
85
+ RecyclerTelemetryGCPassStats* head = this ->lastPassStats ->next ;
86
+ RecyclerTelemetryGCPassStats* curr = head;
87
+ do
88
+ {
89
+ AssertMsg (curr->isGCPassActive == false , " unexpected value for isGCPassActive" );
90
+ count++;
91
+ curr = curr->next ;
92
+ } while (curr != head);
93
+ }
94
+ AssertMsg (count == this ->passCount , " RecyclerTelemetryInfo::StartPass() - mismatch between passCount and count." );
92
95
#endif
93
96
94
- RecyclerTelemetryGCPassStats* p = HeapNewNoThrow (RecyclerTelemetryGCPassStats);
95
- if (p == nullptr )
96
- {
97
- // failed to allocate memory - disable any further telemetry capture for this recycler
98
- // and free any existing GC stats we've accumulated
99
- this ->abortTelemetryCapture = true ;
100
- FreeGCPassStats ();
101
- this ->hostInterface ->TransmitTelemetryError (*this , " Memory Allocation Failed" );
102
- }
103
- else
104
- {
105
- passCount++;
106
- memset (p, 0 , sizeof (RecyclerTelemetryGCPassStats));
107
- if (this ->lastPassStats == nullptr )
97
+ RecyclerTelemetryGCPassStats* p = HeapNewNoThrow (RecyclerTelemetryGCPassStats);
98
+ if (p == nullptr )
108
99
{
109
- p->next = p;
100
+ // failed to allocate memory - disable any further telemetry capture for this recycler
101
+ // and free any existing GC stats we've accumulated
102
+ this ->abortTelemetryCapture = true ;
103
+ FreeGCPassStats ();
104
+ this ->hostInterface ->TransmitTelemetryError (*this , " Memory Allocation Failed" );
110
105
}
111
106
else
112
107
{
113
- p->next = lastPassStats->next ;
114
- this ->lastPassStats ->next = p;
115
- }
116
- this ->lastPassStats = p;
117
-
118
- this ->lastPassStats ->isGCPassActive = true ;
119
- this ->lastPassStats ->passStartTimeTick = Js::Tick::Now ();
120
- GetSystemTimePreciseAsFileTime (&this ->lastPassStats ->passStartTimeFileTime );
121
- if (this ->hostInterface != nullptr )
122
- {
123
- LPFILETIME ft = this ->hostInterface ->GetLastScriptExecutionEndTime ();
124
- this ->lastPassStats ->lastScriptExecutionEndTime = *ft;
125
- }
126
-
127
- this ->lastPassStats ->processCommittedBytes_start = RecyclerTelemetryInfo::GetProcessCommittedBytes ();
128
- this ->lastPassStats ->processAllocaterUsedBytes_start = PageAllocator::GetProcessUsedBytes ();
129
- this ->lastPassStats ->isInScript = this ->recycler ->GetIsInScript ();
130
- this ->lastPassStats ->isScriptActive = this ->recycler ->GetIsScriptActive ();
131
-
132
- this ->FillInSizeData (this ->recycler ->GetHeapInfo ()->GetRecyclerLeafPageAllocator (), &this ->lastPassStats ->threadPageAllocator_start );
133
- this ->FillInSizeData (this ->recycler ->GetHeapInfo ()->GetRecyclerPageAllocator (), &this ->lastPassStats ->recyclerLeafPageAllocator_start );
134
- this ->FillInSizeData (this ->recycler ->GetHeapInfo ()->GetRecyclerLargeBlockPageAllocator (), &this ->lastPassStats ->recyclerLargeBlockPageAllocator_start );
108
+ this ->inPassActiveState = true ;
109
+ passCount++;
110
+ memset (p, 0 , sizeof (RecyclerTelemetryGCPassStats));
111
+ if (this ->lastPassStats == nullptr )
112
+ {
113
+ p->next = p;
114
+ }
115
+ else
116
+ {
117
+ p->next = lastPassStats->next ;
118
+ this ->lastPassStats ->next = p;
119
+ }
120
+ this ->lastPassStats = p;
121
+
122
+ this ->lastPassStats ->isGCPassActive = true ;
123
+ this ->lastPassStats ->passStartTimeTick = Js::Tick::Now ();
124
+ GetSystemTimePreciseAsFileTime (&this ->lastPassStats ->passStartTimeFileTime );
125
+ if (this ->hostInterface != nullptr )
126
+ {
127
+ LPFILETIME ft = this ->hostInterface ->GetLastScriptExecutionEndTime ();
128
+ this ->lastPassStats ->lastScriptExecutionEndTime = *ft;
129
+ }
130
+
131
+ this ->lastPassStats ->processCommittedBytes_start = RecyclerTelemetryInfo::GetProcessCommittedBytes ();
132
+ this ->lastPassStats ->processAllocaterUsedBytes_start = PageAllocator::GetProcessUsedBytes ();
133
+ this ->lastPassStats ->isInScript = this ->recycler ->GetIsInScript ();
134
+ this ->lastPassStats ->isScriptActive = this ->recycler ->GetIsScriptActive ();
135
+
136
+ this ->FillInSizeData (this ->recycler ->GetHeapInfo ()->GetRecyclerLeafPageAllocator (), &this ->lastPassStats ->threadPageAllocator_start );
137
+ this ->FillInSizeData (this ->recycler ->GetHeapInfo ()->GetRecyclerPageAllocator (), &this ->lastPassStats ->recyclerLeafPageAllocator_start );
138
+ this ->FillInSizeData (this ->recycler ->GetHeapInfo ()->GetRecyclerLargeBlockPageAllocator (), &this ->lastPassStats ->recyclerLargeBlockPageAllocator_start );
135
139
#ifdef RECYCLER_WRITE_BARRIER_ALLOC_SEPARATE_PAGE
136
- this ->FillInSizeData (this ->recycler ->GetHeapInfo ()->GetRecyclerWithBarrierPageAllocator (), &this ->lastPassStats ->recyclerWithBarrierPageAllocator_start );
140
+ this ->FillInSizeData (this ->recycler ->GetHeapInfo ()->GetRecyclerWithBarrierPageAllocator (), &this ->lastPassStats ->recyclerWithBarrierPageAllocator_start );
137
141
#endif
138
- this ->lastPassStats ->startPassProcessingElapsedTime = Js::Tick::Now () - start;
139
- }
140
-
142
+ this ->lastPassStats ->startPassProcessingElapsedTime = Js::Tick::Now () - start;
143
+ }
141
144
145
+ }
142
146
}
143
147
144
148
void RecyclerTelemetryInfo::EndPass ()
145
149
{
146
- if (!this ->ShouldCaptureRecyclerTelemetry () )
150
+ if (!this ->inPassActiveState )
147
151
{
148
152
return ;
149
153
}
154
+ this ->inPassActiveState = false ;
150
155
151
156
Js::Tick start = Js::Tick::Now ();
152
157
@@ -220,7 +225,7 @@ namespace Memory
220
225
}
221
226
}
222
227
223
- bool RecyclerTelemetryInfo::ShouldTransmit ()
228
+ bool RecyclerTelemetryInfo::ShouldTransmit () const
224
229
{
225
230
// for now, try to transmit telemetry when we have >= 16
226
231
return (this ->hostInterface != nullptr && this ->passCount >= 16 );
@@ -229,13 +234,13 @@ namespace Memory
229
234
void RecyclerTelemetryInfo::IncrementUserThreadBlockedCount (Js::TickDelta waitTime, RecyclerWaitReason caller)
230
235
{
231
236
#ifdef DBG
232
- if (this ->ShouldCaptureRecyclerTelemetry () )
237
+ if (this ->inPassActiveState )
233
238
{
234
239
AssertMsg (this ->lastPassStats != nullptr && this ->lastPassStats ->isGCPassActive == true , " unexpected Value in RecyclerTelemetryInfo::IncrementUserThreadBlockedCount" );
235
240
}
236
241
#endif
237
242
238
- if (this ->ShouldCaptureRecyclerTelemetry () && this ->lastPassStats != nullptr )
243
+ if (this ->inPassActiveState && this ->lastPassStats != nullptr )
239
244
{
240
245
AssertOnValidThread (this , RecyclerTelemetryInfo::IncrementUserThreadBlockedCount);
241
246
this ->lastPassStats ->uiThreadBlockedTimes [caller] += waitTime;
0 commit comments