zig/lib
mlugg 67e49f190c
std: async read into 1-byte temporary buffer between poll calls on Windows
This commit changes how `std.io.poll` is implemented on Windows. The new
implementation unfortunately incurs a little extra system call overhead,
but fixes a major bug in the old implementation.

I'm not yet set on this implementation, but I'm pushing it to check if
it resolves my CI failures.

The old implementation was buggy in that by leaving `ReadFile` calls
into the `LinearFifo` write end pending between `poll` calls, there was
potential for a race condition where the kernel satisfies the
asynchronous read after the caller has modified the corresponding
`LinearFifo` in some way; most likely by rotating its buffer for a
`readableSliceOfLen` call. The only way to allow the full `LinearFifo`
API to be used is to not leave these `ReadFile` calls pending after
`poll` returns. So, now, `pollWindows` will leave running a different
set of `ReadFile` calls, which are trying to read a single byte into a
temporary buffer. These are the operations we wait on with
`WaitForMultipleObjects`. When these reads are completed, we push that
single byte to the FIFO, and perform some reads directly into the FIFO
memory until we stop getting immediate results; then, we again queue a
single-byte read into a stable buffer for the next call to `poll`.

My main concern with this implementation is that if the kernel
frequently returns `IO_PENDING` for `ReadFile` calls even when the data
is available, then we could effectively skip the bulk-reading path,
hence reading data one byte at a time. Performance measurements are
necessary here.
2024-10-01 06:02:48 +01:00
..
compiler std.Target: Remove Cpu.Arch.dxil and ObjectFormat.dxcontainer. 2024-09-23 17:17:25 -07:00
compiler_rt embrace panic helpers 2024-09-26 16:06:05 -07:00
docs Replace deprecated default initializations with decl literals 2024-09-12 16:01:23 +01:00
fuzzer/web Replace deprecated default initializations with decl literals 2024-09-12 16:01:23 +01:00
include clang: Update compiler-provided C headers to Clang 19.1.0. 2024-09-19 18:20:21 -07:00
init fix init template for new fuzz testing API 2024-09-11 13:41:29 -07:00
libc libc: Work around LLVM's misassembly of j <reg> on mips r6. 2024-09-23 17:26:30 -07:00
libcxx libcxx: Update to LLVM 19.1.0. 2024-09-19 18:20:22 -07:00
libcxxabi libcxxabi: Update to LLVM 19. 2024-09-19 18:20:21 -07:00
libunwind libunwind: Update gcc_personality_v0.c to LLVM 19.1.0. 2024-09-21 01:16:47 +02:00
std std: async read into 1-byte temporary buffer between poll calls on Windows 2024-10-01 06:02:48 +01:00
tsan tsan: Update to LLVM 19.1.0. 2024-09-24 23:58:21 -07:00
c.zig compiler,lib,test,langref: migrate @setCold to @branchHint 2024-08-27 00:44:35 +01:00
compiler_rt.zig stage2-wasm: bit_reverse 2024-06-16 11:53:33 +02:00
fuzzer.zig Replace deprecated default initializations with decl literals 2024-09-12 16:01:23 +01:00
zig.h zig.h: Improve portability of zig_trap() and zig_breakpoint(). 2024-09-23 17:34:15 -07:00