You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: build on Windows via portable *os.File positional I/O
The core write/read paths imported golang.org/x/sys/unix (unix.Pwrite/Pread
on cached raw int fds), as did platform_other.go, so the library failed to
compile on Windows — breaking any downstream module that imports it on a
Windows runner.
Replace the raw-fd syscalls with *os.File.WriteAt/ReadAt, which map to
pwrite/pread on Unix and OVERLAPPED I/O on Windows and preserve the lock-free
concurrent positioned-write property (Go's internal/poll uses incref, not a
write lock, for positional I/O). Change preallocFile to take *os.File and route
the !linux && !darwin fallback through os.File.Truncate, which needs no unix
import and also covers Windows, so no dedicated platform_windows.go is required.
Only platform_linux.go (fallocate) and platform_darwin.go (F_PREALLOCATE) still
use x/sys/unix.
Result: the sorted builder and all query/read paths build and work on Windows.
The unsorted builder still relies on the POSIX unlink-while-open idiom for its
temp files, which Windows rejects, so NewUnsortedBuilder is unsupported there.
Benchmarks (10M keys, ptrhash, 7 iters, before/after) show build throughput
unchanged within noise: sorted +1.8%, unsorted +1.3%, unsorted cw=4 +3.0%
medians — all within the ~5% band. The added WriteAt/ReadAt cost is a couple of
atomic refcount ops per syscall, dwarfed by the ~µs syscall.
Windows compilation verified via GOOS=windows cross-compile; CI still runs
ubuntu + macos only.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments