-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Console.OpenStandard* few times slower on Linux #31396
Comments
Quick look at the profile: private static void Main(string[] args)
{
for (int i = 0; i < 10_000_000; i++)
{
using (var output = Console.OpenStandardOutput())
{
};
}
} 20% of time is spent in call to Which sets |
@adamsitnik this issue can be closed. |
@tmds When I created this issue I was hoping that somebody is going to perform a full investigation and bring the performance on par with Windows. We have solved only the low hanging fruit (20%) and the difference is still very big. That's why I would perfer to keep it open. |
Digging a bit deeper. The highest cost comes from the syscalls involved: Windows makes 1 for open, and runtime/src/libraries/System.Console/src/System/ConsolePal.Windows.cs Lines 1104 to 1113 in 886e442
Unix makes 1 for open, and runtime/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs Lines 110 to 126 in 886e442
The |
@adamsitnik is the above analysis good enough to close this issue? |
It is! Thank you @tmds! |
Console.OpenStandard* methods are few times slower on Linux.
How to run the benchmarks:
Recommended profilers are PerfCollect and VTune.
The text was updated successfully, but these errors were encountered: