go: runtime: use epoll_pwait2 where available for sub-millisecond timeout precision on Linux
Linux kernel 5.11 (February, 2021) added the epoll_pwait2 system call. It is exactly like epoll_pwait except that the timeout argument is a struct timespec. This permits specifying a timeout with nanosecond precision, where epoll_pwait and epoll_wait only permit millisecond precision. We should change runtime/netpoll_epoll.go to use epoll_pwait2 when available to get higher precision delays.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 9
- Comments: 24 (24 by maintainers)
Commits related to this issue
- runtime: move epoll syscalls to runtime/internal/syscall This change moves Linux epoll's syscalls implementation to the "runtime/internal/syscall" package. The intention in this CL was to minimise be... — committed to golang/go by dAdAbird 4 years ago
- Revert "runtime: move epoll syscalls to runtime/internal/syscall" This reverts CL 421994. Reason for revert: breaks runtime.TestCheckPtr2 For #53824 For #51087 Change-Id: I044ea4d6efdffe0a4b7fb0d2... — committed to golang/go by prattmic 4 years ago
- runtime: move epoll syscalls to runtime/internal/syscall This change moves Linux epoll's syscalls implementation to the "runtime/internal/syscall" package. The intention in this CL was to minimise be... — committed to golang/go by dAdAbird 4 years ago
- runtime: move epoll syscalls to runtime/internal/syscall This change moves Linux epoll's syscalls implementation to the "runtime/internal/syscall" package. The intention in this CL was to minimise be... — committed to TroutSoftware/go by dAdAbird 4 years ago
- time: mention time resolution in docs Updates #44343 Updates #53824 Change-Id: Ia7234fac4b1b88b3c331328aaa98dc85205e09ba Reviewed-on: https://go-review.googlesource.com/c/go/+/514275 Reviewed-by: Da... — committed to golang/go by qmuntal 3 years ago
I think for now you can just add the epoll constants you need for the CL.
For the syscall number constants, I would create new per-arch files in
runtime/internal/syscallto define those constants. Eventually, we’ll want to shift all of the constants out ofsys_linux_xxx.sand into that package (and ideally generate them).Which packages the runtime can import are very restricted, so it wouldn’t be able to import
golang.org/x/sys/unix. We might eventually want to use the same code generation mechanism for both, but that’s down the road.The constant
_ENOSYSwas removed from the runtime package in https://go.dev/cl/389354. It would be fine to revert that part of that CL for this purpose.Since this is Linux-only, it could use the new runtime/internal/syscall package, rather than implementing it in assembly for all architectures.
Mostly because I simply haven’t gotten around to it. You are welcome to base a change off of my CL.
I also did want to do some benchmarking (probably with https://cs.opensource.google/go/x/benchmarks/+/master:sweet/) to check for performance regressions, since more precise timeouts could potentially lead to more frequent wakeups.
Thanks. I suggest that you sketch out what you will do before implementing, to make sure that it seems like a good approach.
Does anybody work on this? I can take on it.