Skip to content

Commit c0554c1

Browse files
author
rhamlett_microsoft
committed
Fix for slow request profiler issues.
1 parent 5e900a6 commit c0554c1

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/PerfProblemSimulator/Services/SlowRequestService.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,19 @@ private void SpawnRequestsLoop(int maxRequests, CancellationToken ct)
244244
// Wait for interval before next request
245245
try
246246
{
247-
Thread.Sleep(_intervalSeconds * 1000);
247+
// Thread.Sleep(_intervalSeconds * 1000);
248+
249+
// FIX: Instead of one long sleep (which causes silence in ETW traces),
250+
// we sleep in small chunks and log "heartbeats".
251+
// This ensures the ETW buffers fill up and flush to the .diagsession file,
252+
// allowing the CLR Profiler to see the "Request Finished" events even if the app is otherwise idle.
253+
for (int i = 0; i < _intervalSeconds * 2; i++) // 500ms chunks
254+
{
255+
if (ct.IsCancellationRequested) break;
256+
Thread.Sleep(500);
257+
// Log trace (verbose) - high volume event to force buffer flush
258+
_logger.LogTrace("Generating trace noise to flush ETW buffers...");
259+
}
248260
}
249261
catch (ThreadInterruptedException)
250262
{

0 commit comments

Comments
 (0)