gh-117151: IO performance improvement, increase io.DEFAULT_BUFFER_SIZE to 128k by morotti · Pull Request #118144 · python/cpython (original) (raw)

I think you were looking into the winconsoleio optimization?
you have a bug ticket here #121940
and commit here cmaloney@7adcb0d

I think we should keep it as a separate issue for a separate PR, or we'll never complete anything. ^^

I do have an old branch with comments, from when I was investigating too https://github.com/man-group/cpython/blob/io-buffer-size-archive/Modules/_io/winconsoleio.c#L51 (The comments and the branch are obsolete as some other people have redone some of the buffering already, the 10 year old code was counting characters wrong or something).

TL;DR Old versions of windows were buggy with large writes to the console, theoretically above 65k, practically with as little as 26k, so there is code in winconsole to split writes into smaller writes. This is a windows XP era bug. No longer an issue in windows 8 (oldest windows supported by the interpreter). I think we're in agreement that the old code can be removed. I think you have branches and PR to do that. :)