-
Notifications
You must be signed in to change notification settings - Fork 588
win32_isatty() dont call a mostly failing syscall, NT->WIN err conv is slow #23375
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
base: blead
Are you sure you want to change the base?
Conversation
bulk88
commented
Jun 17, 2025
- This set of changes does not require a perldelta entry.
It definitely speeds up the test against file type file handles, from ~1.2µs to 0.39µs per call. It slows down the test against tty handles a little, from ~23.8-24.5µs to 23.4-25.0µs. |
Good to know it was a verified benchmark improvement? How did you measure it? Just curious. Maybe I can do it as routine. I didn't benchmark it myself, but that RtlNtErr2WinErr() function made me furious single stepping its Asm code. Its a 0-65000 Its probably worse than I have another patch somewhere that cuts down the number win32_isatty() calls coming from the POSIX-y PerlIO .c code by an order of magnitude (90%), but I want to get this patch in first, which makes the win32_isatty() impl better, regardless of goodness or badness, of whatever the caller frame's code is doing. The patch that removes The Win32 Console APIs aren't known for being I/O speed demons. Plus waking up I could've done Native API/Asm style optimizations inside win32_isatty() but I decided that is a bad idea, MS in late Win10s era/Win 11 era has done heavy refactoring on Safer and easier and less thinking and less work to off load responsibility for all the shortcut tricks to
Remember MS specifically says Win RT Apps/MS Mobile App Store walled garden Apps, probably are forbidden from C linking against I'd have to double check, but I believe the MS's API Sets and
random facts: |
It wasn't anything too rigorous:
tested 3 times each with blead and with your change. blead results (Ryzen 7 2700):
with your change:
Debian (i7-10700F):
Debian (WSL2, Ryzen 7 2700, same hardware as Windows above)
|
I would merge this if the commit message is improved enough. But I object to its merging as-is. The code itself looks fine to me. First, the commit message title is too long. GH was forced to wrap it, using ellipses. And what is there doesn't really help me understand what's happening. It is actually factually wrong. This commit doesn't stop calling any syscall. It inserts another syscall first and avoids calling the original one if that one fails. It also assumes a more intimate knowledge of Windows internals than I possess, and I'm sure I'm not alone. "NT->Winn err conv is slow" is something I can guess at what it means. But it shouldn't be in a commit title Second the commit message body is non-existent, and the comments refer the reader to the p.r. for details. The comments should not refer to an unspecified GH p.r. that someone would have to take steps to track down. It is ok to refer to the commit message that created them. But making a later reader have to go through the extra level of indirection is unacceptable. Third, the p.r. description isn't very helpful. People reading this want to know what is changing and why. Starting off with a description of the internals of a Windows library function does not meet that need. I myself would not have included it, but if you feel that background is helpful to people more attuned to Windows internals than I and most of the people who will ever read the message, then it should be placed in a separate paragraph later. The p.r. description should be copied into the commit message in this case. And it is a non-sequitor with its title. Its first sentence needs to expand on what the title says. It doesn't currently. What it looks to me is that the commit basically finds many failures using a faster but incomplete syscall before falling back to the slow complete one. But I wouldn't have figured that out from any of your descriptions. The "Let them read code" attitude is not a principal compatible with this project. (Today I learned that Marie Antoinette did not say the similar phrase attributed to her; that claim was first made 50 years after her execution.) Writing a good commit message for anything but trivial changes takes some effort. We require that pull requests have had sufficient effort not just in the code but in its comments and descriptions. |
@@ -4000,7 +4000,10 @@ win32_isatty(int fd) | |||
return 0; | |||
} | |||
|
|||
if (GetConsoleMode(fh, &mode)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the description says there is a syscall that mostly fails. There is nothing that explains that statement, so we are left to guess about it.