runtime: [arm64] Perf_FileStream.FlushAsync benchmark hangs on Debian 11

Reported by @carlossanlop offline. Carlos has hit this issue on Debian 11 arm64 with WSL2.

Repro:

git clone https://github.com/dotnet/performance.git
python3 ./performance/scripts/benchmarks_ci.py --architecture arm64 -f net7.0 --filter '*Perf_FileStream.FlushAsync*'

Source:

using (FileStream fileStream = new FileStream("repro.txt", FileMode.Create, FileAccess.Write, FileShare.Read, 4096, FileOptions.None))
{
    for (int i = 0; i < 1024; i++)
    {
        fileStream.WriteByte(default);

        await fileStream.FlushAsync();
    }
}

In theory it could be an IO issue, but we have not touched FileStream for a few months and I suspect that it’s a runtime bug similar to #64980.

@janvorli @jkotas what would be the best way to determine the reason of the hang on Linux?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (21 by maintainers)

Commits related to this issue

Most upvoted comments

I have investigated the issue and the problem is in threadpool not processing a work item. As you can see from the SOS command below, there are no worker threads, the work request queue has 0 items and yet there is a queued work item. At this point, the process is waiting for that work item completion and nothing happens.

(lldb) threadpool -wi
logStart: 0
logSize: 17
CPU utilization: 0 %
Worker Thread: Total: 0 Running: 0 Idle: 0 MaxLimit: 32767 MinLimit: 8
Work Request in Queue: 0

Queued work items:
Queue Address Work Item
00007efb4283a718 00007efb42300258 Microsoft.Win32.SafeHandles.SafeFileHandle+ThreadPoolValueTaskSource
Statistics:
MT Count TotalSize Class Name
00007f3b59025970 1 152 Microsoft.Win32.SafeHandles.SafeFileHandle+ThreadPoolValueTaskSource
Total 1 objects

--------------------------------------
Number of Timers: 0
--------------------------------------
Completion Port Thread:Total: 0 Free: 0 MaxFree: 0 CurrentLimit: 0 MaxLimit: 1000 MinLimit: 0

@adamsitnik sure, I’ll take a look.

FYI - I hit this hang in:

  • Ubuntu 20.04 x64 (Physical laptop)
  • Ubuntu 20.04 arm64 (WSL)
  • Debian 11 (WSL)

I uploaded the dump file to the location where we’re posting our manual run results. And I observed a peculiar behavior:

  • While plugged in, on the Windows host Performance power plan, the benchmark hangs frequently (but not every time)
  • When on battery power, on the Performance power plan, I’ve been unable to repro the hang
  • When plugged in or on battery power, on the Balanced power plan, I’ve been unable to repro the hang