runtime: Performance of System.Console.CursorLeft and System.Console.CursorTop is really, really bad in .NET Core 2.1.2 on Linux
Test case:
I am trying to use this library as a progress bar for a netcoreapp2.1
console app on Linux. However, I found that since it uses System.Console.CursorLeft
and System.Console.CursorTop
frequently (in loops), that it was completely unusable. If you click on the link, there are some GIFs in the README that show the demo program completing in about 15-20 seconds. I let the demo program run on .NET Core 2.1.2 on Linux for 12 hours!!! and it was still on 0%. I did some profiling on this and found that 50% of the CPU time was in system calls to the kernel reading and writing stdin.
I’ve read all of the comments in https://github.com/dotnet/corefx/blob/master/src/System.Console/src/System/ConsolePal.Unix.cs, so I understand that there are always going to be performance issues with this on Unix platforms, but this seems so extreme that surely it can be improved somewhat.
I made this pull request to work around the issue, so hopefully it might help anyone else facing slowdowns because of this.
Steps to reproduce:
git clone https://github.com/Mpdreamz/shellprogressbar.git
git checkout 21a516004680
for netcoreapp1.1 orgit checkout cd998d37d7f7
for netcoreapp2.1dotnet run -p src/ShellProgressBar.Example
$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.1.302
Commit: 9048955601
Runtime Environment:
OS Name: ubuntu
OS Version: 18.04
OS Platform: Linux
RID: ubuntu.18.04-x64
Base Path: /usr/share/dotnet/sdk/2.1.302/
Host (useful for support):
Version: 2.1.2
Commit: 811c3ce6c0
.NET Core SDKs installed:
2.1.302 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.1.9 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (12 by maintainers)
Commits related to this issue
- Solve the issue of console flicker (#286) — committed to neo-project/neo-node by Jim8y 5 years ago
@dlech - want to test your fuzzy thinking relative to 1.x having better perf?
I made my own GIF so you can see just how slow it is in comparison. 😄