dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.12k stars 4.7k forks source link

HttpClient parallel requests hang on macOS #82634

Closed marmazey closed 1 year ago

marmazey commented 1 year ago

Description

Running many parallel requests with HttpClient on macOS M1 processor from Visual Studio for Mac causes the C# application to hang. Pressing Pause in VS has no reaction. Pressing Stop will terminate the debugging mode, but 'dotnet' process started by 'vsdbg' is still in memory with ~100-200% of cpu usage.

Code repository: https://github.com/marmazey/TestParallelHttpRequests

Configuration

.Net 7.0.3 Visual Studio for Mac 17.5 (build 1802) .Net Location used: /usr/local/share/dotnet/x64/dotnet (x64 version) macOS Ventura 13.2.1 on M1 (ARM64) https:// in url 1000 requests from 100 threads reproducibility: 1 of 3

Regression

Reproduced with .Net 6.0.14

ghost commented 1 year ago

Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.

Issue Details
### Description Running many parallel requests with HttpClient on macOS M1 processor from Visual Studio for Mac causes the C# application to hang. Pressing Pause in VS has no reaction. Pressing Stop will terminate the debugging mode, but 'dotnet' process started by 'vsdbg' is still in memory with ~100-200% of cpu usage. Code repository: https://github.com/marmazey/TestParallelHttpRequests ### Configuration .Net 7.0.3 Visual Studio for Mac 17.5 (build 1802) .Net Location used: /usr/local/share/dotnet/x64/dotnet (x64 version) macOS Ventura 13.2.1 on M1 (ARM64) https:// in url 1000 requests from 100 threads reproducibility: 1 of 3 ### Regression Reproduced with .Net 6.0.14
Author: marmazey
Assignees: -
Labels: `area-System.Net.Http`, `untriaged`
Milestone: -
wfurt commented 1 year ago

I cannot speak for the vsdb & VS4Mac. But I see the "no activity" messages even on Linux. There may be be issue with the synchronization in the repro or the site. (or the VS but that is beyond runtime scope)

marmazey commented 1 year ago

"No logger activity in last 3 seconds" messages means that WatcherLoop thread is working. But I often reproduce the situation when even this "No logger activity" message does not appear = all my threads are suspended, but CPU is usage still high.

CarnaViire commented 1 year ago

Triage: putting to Future for now. @marmazey are you able to reproduce the issue only in VisualStudio for Mac, or does it happen when started from CLI? Is it reproducible on other platforms, e.g. Linux?

ghost commented 1 year ago

This issue has been marked needs-author-action and may be missing some important information.

marmazey commented 1 year ago
  1. This issue is reproduced only when starting the example from VisualStudio for Mac (Debug -> Start Debugging).
  2. It is not reproduced from CLI on Mac, or when started from VS for Mac without debugging.
  3. It is not reproduced from CLI on Linux.
ManickaP commented 1 year ago

@marmazey could you collect a dump from the hanging process? And either investigate it yourself or share it with us to see where the process gets stuck.

From the description of the problem, it doesn't look like this is unambiguously HttpClient issue, it might be an issue with the debugger, or with your test code.

ghost commented 1 year ago

This issue has been marked needs-author-action and may be missing some important information.

ManickaP commented 1 year ago

Triage: there's nothing actionable for us until this is proven to be HttpClient issue. We'll need a dump to investigate further. Also this might prove as problem elsewhere.

ghost commented 1 year ago

This issue has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

ghost commented 1 year ago

This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.