dotnet / dotnet/aspnetcore

default logging to console has bad perf on windows, should be disabled by default

Open
#40,770 3 comments 0 reactions 0 assignees View on GitHub
area-networking investigate Perf
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

this is without much logging and it's taking up 8.8% inclusive CPU. disabling colors didn't help. it's just really non performant to log to console on windows. please consider disabling this by default.

+ Thread (10844) CPU=1886ms (Console logger queue processing thread) | 8.8 | 1,886
\|+ ntdll!RtlUserThreadStart | 8.5 | 1,836
\|\|+ kernel32!BaseThreadInitThunk | 8.5 | 1,836
\|\| + coreclr!ThreadNative::KickOffThread | 8.5 | 1,836
\|\|  + coreclr!ManagedThreadBase_DispatchOuter | 8.5 | 1,836
\|\|   + coreclr!ManagedThreadBase_DispatchMiddle | 8.5 | 1,836
\|\|    + coreclr!ThreadNative::KickOffThread_Worker | 8.5 | 1,836
\|\|     + coreclr!DispatchCallSimple | 8.5 | 1,836
\|\|      + coreclr!CallDescrWorkerInternal | 8.5 | 1,836
\|\|       + system.private.corelib!System.Threading.Thread::StartCallback() | 8.5 | 1,836
\|\|        + microsoft.extensions.logging.console!Microsoft.Extensions.Logging.Console.ConsoleLoggerProcessor::ProcessLogQueue() | 8.5 | 1,836
\|\|         + Microsoft.Extensions.Logging.Console.il!AnsiParser.Parse | 5.1 | 1,106
\|\|         \|+ Microsoft.Extensions.Logging.Console.il!AnsiParsingLogConsole.WriteToConsole | 5.0 | 1,070
\|\|         \|\|+ system.console.il!ConsolePal.set_BackgroundColor | 1.6 | 347
\|\|         \|\|\|+ system.console.il!ConsolePal.GetBufferInfo | 1.6 | 345
\|\|         \|\|\|\|+ system.console.il!dynamicClass.IL_STUB_PInvoke(int,value class CONSOLE_SCREEN_BUFFER_INFO&) | 1.5 | 333

### Expected Behavior

for something so non performant, should disable by default or change to another form of logging (ie to a file).

### Steps To Reproduce

I have an internal app that I cannot share - if you can't repro feel free to let me know.

### Exceptions (if any)

_No response_

### .NET Version

.net 6

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.