aboutsummaryrefslogtreecommitdiff
path: root/src/internal/poll
AgeCommit message (Collapse)Author
2024-01-23net,internal/poll: load ws2_32.dll only when net is importedqmuntal
On Windows, ws2_32.dll is loaded and WSA initialized even if websockets are not used. This CL delays loading of ws2_32.dll and starting WSA until net is initialized. Change-Id: I07ea8241d79709cd4e80d29ba0d792c7444bbfe9 Reviewed-on: https://go-review.googlesource.com/c/go/+/557015 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-01-23runtime,internal/poll: move websocket handling out of the runtime on Windowsqmuntal
On Windows, the netpoll is currently coupled with the websocket usage in the internal/poll package. This CL moves the websocket handling out of the runtime and puts it into the internal/poll package, which already contains most of the async I/O logic for websockets. This is a good refactor per se, as the Go runtime shouldn't know about websockets. In addition, it will make it easier (in a future CL) to only load ws2_32.dll when the Go program actually uses websockets. Change-Id: Ic820872cf9bdbbf092505ed7f7504edb6687735e Reviewed-on: https://go-review.googlesource.com/c/go/+/556936 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-12-18internal/syscall/windows: fix the signature of SetFileInformationByHandleBryan C. Mills
Also fix its call site in internal/poll to pass the length of the actual buffer instead of an unrelated variable, and update the definition of FILE_BASIC_INFO to match the documented field types and add padding that is empirically needed on the 386 architecture. Passing a pointer to a Go-allocated buffer as type uintptr violates the unsafe.Pointer conversion rules, which allow such a conversion only in the call expression itself for a call to syscall.Syscall or equivalent. That can allow the buffer to be corrupted arbitrarily if the Go runtime happens to garbage-collect it while the call to SetFileInformationByHandle is in progress. The Microsoft documentation for SetFileInformationByHandle specifies its third argument type as LPVOID, which corresponds to Go's unsafe.Pointer, not uintptr. Fixes #58933 (maybe). Change-Id: If577b57adea9922f5fcca55e46030c703d8f035c Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/549256 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2023-11-17net,os: arrange zero-copy of os.File and net.TCPConn to net.UnixConnAndy Pan
Fixes #58808 goos: linux goarch: amd64 pkg: net cpu: DO-Premium-Intel │ old │ new │ │ sec/op │ sec/op vs base │ Splice/tcp-to-unix/1024-4 3.783µ ± 10% 3.201µ ± 7% -15.40% (p=0.001 n=10) Splice/tcp-to-unix/2048-4 3.967µ ± 13% 3.818µ ± 16% ~ (p=0.971 n=10) Splice/tcp-to-unix/4096-4 4.988µ ± 16% 4.590µ ± 11% ~ (p=0.089 n=10) Splice/tcp-to-unix/8192-4 6.981µ ± 13% 5.236µ ± 9% -25.00% (p=0.000 n=10) Splice/tcp-to-unix/16384-4 10.192µ ± 9% 7.350µ ± 7% -27.89% (p=0.000 n=10) Splice/tcp-to-unix/32768-4 19.65µ ± 13% 10.28µ ± 16% -47.69% (p=0.000 n=10) Splice/tcp-to-unix/65536-4 41.89µ ± 18% 15.70µ ± 13% -62.52% (p=0.000 n=10) Splice/tcp-to-unix/131072-4 90.05µ ± 11% 29.55µ ± 10% -67.18% (p=0.000 n=10) Splice/tcp-to-unix/262144-4 170.24µ ± 15% 52.66µ ± 4% -69.06% (p=0.000 n=10) Splice/tcp-to-unix/524288-4 326.4µ ± 13% 109.3µ ± 11% -66.52% (p=0.000 n=10) Splice/tcp-to-unix/1048576-4 651.4µ ± 9% 228.3µ ± 14% -64.95% (p=0.000 n=10) geomean 29.42µ 15.62µ -46.90% │ old │ new │ │ B/s │ B/s vs base │ Splice/tcp-to-unix/1024-4 258.2Mi ± 11% 305.2Mi ± 8% +18.21% (p=0.001 n=10) Splice/tcp-to-unix/2048-4 492.5Mi ± 15% 511.7Mi ± 13% ~ (p=0.971 n=10) Splice/tcp-to-unix/4096-4 783.5Mi ± 14% 851.2Mi ± 12% ~ (p=0.089 n=10) Splice/tcp-to-unix/8192-4 1.093Gi ± 11% 1.458Gi ± 8% +33.36% (p=0.000 n=10) Splice/tcp-to-unix/16384-4 1.497Gi ± 9% 2.076Gi ± 7% +38.67% (p=0.000 n=10) Splice/tcp-to-unix/32768-4 1.553Gi ± 11% 2.969Gi ± 14% +91.17% (p=0.000 n=10) Splice/tcp-to-unix/65536-4 1.458Gi ± 23% 3.888Gi ± 11% +166.69% (p=0.000 n=10) Splice/tcp-to-unix/131072-4 1.356Gi ± 10% 4.131Gi ± 9% +204.72% (p=0.000 n=10) Splice/tcp-to-unix/262144-4 1.434Gi ± 13% 4.637Gi ± 4% +223.32% (p=0.000 n=10) Splice/tcp-to-unix/524288-4 1.497Gi ± 15% 4.468Gi ± 10% +198.47% (p=0.000 n=10) Splice/tcp-to-unix/1048576-4 1.501Gi ± 10% 4.277Gi ± 16% +184.88% (p=0.000 n=10) geomean 1.038Gi 1.954Gi +88.28% │ old │ new │ │ B/op │ B/op vs base │ Splice/tcp-to-unix/1024-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ Splice/tcp-to-unix/2048-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ Splice/tcp-to-unix/4096-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ Splice/tcp-to-unix/8192-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ Splice/tcp-to-unix/16384-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ Splice/tcp-to-unix/32768-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ Splice/tcp-to-unix/65536-4 1.000 ± ? 0.000 ± 0% -100.00% (p=0.001 n=10) Splice/tcp-to-unix/131072-4 2.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10) Splice/tcp-to-unix/262144-4 4.000 ± 25% 0.000 ± 0% -100.00% (p=0.000 n=10) Splice/tcp-to-unix/524288-4 7.500 ± 33% 0.000 ± 0% -100.00% (p=0.000 n=10) Splice/tcp-to-unix/1048576-4 17.00 ± 12% 0.00 ± 0% -100.00% (p=0.000 n=10) geomean ² ? ² ³ ¹ all samples are equal ² summaries must be >0 to compute geomean ³ ratios must be >0 to compute geomean │ old │ new │ │ allocs/op │ allocs/op vs base │ Splice/tcp-to-unix/1024-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ Splice/tcp-to-unix/2048-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ Splice/tcp-to-unix/4096-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ Splice/tcp-to-unix/8192-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ Splice/tcp-to-unix/16384-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ Splice/tcp-to-unix/32768-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ Splice/tcp-to-unix/65536-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ Splice/tcp-to-unix/131072-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ Splice/tcp-to-unix/262144-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ Splice/tcp-to-unix/524288-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ Splice/tcp-to-unix/1048576-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ geomean ² +0.00% ² ¹ all samples are equal ² summaries must be >0 to compute geomean Change-Id: I829061b009a0929a8ef1a15c183793c0b9104dde Reviewed-on: https://go-review.googlesource.com/c/go/+/472475 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-23net,internal/poll: mark it as handled even if sendfile(2) succeeded with 0 ↵Andy Pan
bytes sent CL 415834 fixed #53658 and somehow it only fixed it on Linux, sendfile can also succeed with 0 bytes sent on other platforms according to their manuals, this CL will finish the work that CL 415834 left out on other platforms. goos: darwin goarch: arm64 pkg: net │ old │ new │ │ sec/op │ sec/op vs base │ SendfileZeroBytes-10 7.563µ ± 5% 7.184µ ± 6% -5.01% (p=0.009 n=10) │ old │ new │ │ B/op │ B/op vs base │ SendfileZeroBytes-10 3562.5 ± 7% 590.0 ± 2% -83.44% (p=0.000 n=10) │ old │ new │ │ allocs/op │ allocs/op vs base │ SendfileZeroBytes-10 0.00 ± 0% 11.00 ± 0% ? (p=0.000 n=10) [1] https://man.freebsd.org/cgi/man.cgi?sendfile(2) [2] https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendfile.2.html [3] https://man.dragonflybsd.org/?command=sendfile&section=2 [4] https://docs.oracle.com/cd/E88353_01/html/E37843/sendfile-3c.html Change-Id: I55832487595ee8e0f44f367cf2a3a1d827ba590d Reviewed-on: https://go-review.googlesource.com/c/go/+/536455 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-10-19internal/poll: add SPLICE_F_NONBLOCK flag for splice to avoid inconsistency ↵Andy Pan
with O_NONBLOCK For #59041 Details: https://github.com/golang/go/issues/59041#issuecomment-1766610087 Change-Id: Id3fc1df6d86b7c4cc383d09f9465fa8f4cc2a559 Reviewed-on: https://go-review.googlesource.com/c/go/+/536015 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-08-30internal/poll, net: use (*FD).SetsockoptInet4Addr in ↵Tobias Klauser
setIPv4MulticastInterface on windows Change-Id: Ic29d15bf62d8e693ca969354b415d958823bf41d Reviewed-on: https://go-review.googlesource.com/c/go/+/523915 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2023-06-07internal/poll: update SOCK_CLOEXEC commentIan Lance Taylor
For #45964 For #59359 Change-Id: I9f8f4c17ccd9711f81d152953a5e6aea50c6a28f Reviewed-on: https://go-review.googlesource.com/c/go/+/501636 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-06-07Revert "internal/poll: remove fallback path in accept"Ian Lance Taylor
This reverts CL 422375. Reason for revert: We still need the fallback path on Solaris. For #45964 For #59359 Change-Id: Ie598b9ef180708fb157080015aee44f67f6737c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/501275 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2023-05-25net: implement wasip1 FileListener and FileConnChris O'Hara
Implements net.FileListener and net.FileConn for wasip1. net.FileListener can be used with a pre-opened socket. If the WASM module knows the file descriptor, a listener can be constructed with: l, err := net.FileListener(os.NewFile(fd, "")) If the WASM module does not know the file descriptor, but knows that at least one of the preopens is a socket, it can find the file descriptor and construct a listener like so: func findListener() (net.Listener, error) { // We start looking for pre-opened sockets at fd=3 because 0, 1, // and 2 are reserved for stdio. Pre-opened directories also // start at fd=3, so we skip fds that aren't sockets. Once we // reach EBADF we know there are no more pre-opens. for preopenFd := uintptr(3); ; preopenFd++ { l, err := net.FileListener(os.NewFile(preopenFd, "")) var se syscall.Errno switch errors.As(err, &se); se { case syscall.ENOTSOCK: continue case syscall.EBADF: err = nil } return l, err } } A similar strategy can be used with net.FileConn and pre-opened connection sockets. The wasmtime runtime supports pre-opening listener sockets: $ wasmtime --tcplisten 127.0.0.1:8080 module.wasm Change-Id: Iec6ae4ffa84b3753cce4f56a2817e150445db643 Reviewed-on: https://go-review.googlesource.com/c/go/+/493358 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Bypass: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-05-25runtime: implement wasip1 netpollChris O'Hara
Implements netpoll using WASI's poll_oneoff system call. This enables non-blocking I/O support for wasip1. Change-Id: Ie395fa49d651c8b8262d485e2847dd65b0a10bc6 Reviewed-on: https://go-review.googlesource.com/c/go/+/493357 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Julien Fabre <ju.pryz@gmail.com> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2023-05-19internal/poll: handle SetDeadline to time.Now() in Plan 9miller
The implementation of SetDeadline in Plan 9 begins by calculating d = the offset of the requested deadline from time.Now(). If d > 0, a timer is set to interrupt future I/O. If d < 0, the channel is flagged to prevent future I/O and any current I/O is cancelled. But if d = 0, nothing happens and the deadline isn't set. The d = 0 case should be handled the same as d < 0. Fixes #60282 Fixes #52896 Change-Id: Id8167db3604db1c129d99376fa78a3da75417d20 Reviewed-on: https://go-review.googlesource.com/c/go/+/496137 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: David du Colombier <0intro@gmail.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-05-18internal/poll, internal/syscall/unix, net: move and export fcntl syscall wrapperTobias Klauser
This will allow to use the fcntl syscall in packages other than internal/poll. For #60181 Change-Id: I76703766a655f2343c61dad95faf81aad58e007f Reviewed-on: https://go-review.googlesource.com/c/go/+/494916 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-09syscall,internal/poll: move pipe check from syscall.Seek to callersqmuntal
On Windows, syscall.Seek is a thin wrapper over SetFilePointerEx [1], which does not work on pipes, although it doesn't return an error on that case. To avoid this undefined behavior, Seek defensively calls GetFileType and errors if the type is FILE_TYPE_PIPE. The problem with this approach is that Seek is a low level foundational function that can be called many times for the same file, and the additional cgo call (GetFileType) will artificially slow down seek operations. I've seen GetFileType to account for 10% of cpu time in seek-intensive workloads. A better approach, implemented in this CL, would be to move the check one level up, where many times the file type is already known so the GetFileType is unnecessary. The drawback is that syscall.Seek has had this behavior since pipes where first introduced to Windows in https://codereview.appspot.com/1715046 and someone could be relying on it. On the other hand, this behavior is not documented, so we couldn't be breaking any contract. [1] https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-setfilepointerex Change-Id: I7602182f9d08632e22a8a1635bc8ad9ad35a5056 Reviewed-on: https://go-review.googlesource.com/c/go/+/493626 Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-04-27all: remove repeated definite articlescui fliter
Change-Id: Idea3e6ca6e62bd5a5ff6e6d5c3f39efb7628f0ec Reviewed-on: https://go-review.googlesource.com/c/go/+/489635 Run-TryBot: Michael Pratt <mpratt@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
2023-04-18internal/poll: add GetsockoptIntMatthieu Baerts
This new function wraps the getsockopt network call with an integer argument, similar to SetsockoptInt. This will be used in MPTCP in the following commit. This work has been co-developed by Gregory Detal <gregory.detal@tessares.net>. Updates #59166 Change-Id: I8f6aa00ea2535683d9bbf436993c23e9c6ca2af3 Reviewed-on: https://go-review.googlesource.com/c/go/+/471139 Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-04-11runtime: filter i/o async entries using completion key on windowsWill Hawkins
In the case where a user program requests overlapped I/O directly on a handlethat is managed by the runtime, it is possible that runtime.netpoll will attempt to dereference a pointer with an invalid value. This CL prevents the runtime from accessing the invalid pointer value by adding a special key to each overlapped I/O operation that it creates. Fixes #58870 Co-authored-by: quimmuntal@gmail.com Change-Id: Ib58ee757bb5555efba24c29101fc6d1a0dedd61a Reviewed-on: https://go-review.googlesource.com/c/go/+/482495 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-04-07internal: add wasip1 supportJohan Brandhorst-Satzkorn
For #58141 Co-authored-by: Richard Musiol <neelance@gmail.com> Co-authored-by: Achille Roussel <achille.roussel@gmail.com> Co-authored-by: Julien Fabre <ju.pryz@gmail.com> Co-authored-by: Evan Phoenix <evan@phx.io> Change-Id: I1488726e5b43cd21c5f83900476afd2fb63d70c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/479622 Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
2023-03-15os, internal/poll: don't use splice with ttyIan Lance Taylor
Also don't try to wait for a non-pollable FD. Fixes #59041 Change-Id: Ife469d8738f2cc27c0beba223bdc8f8bc757b2a7 Reviewed-on: https://go-review.googlesource.com/c/go/+/476335 Run-TryBot: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-03-02internal/poll: remove redundant atomics from poll.FD on plan9miller
After CL 235820 all references to FD.rtimedout and FD.wtimedout are guarded by mutexes. Therefore they can safely be changed from type atomic.Bool to bool. Change-Id: I7ab921d1ad5c7ccc147feb2b0fba58a66b031261 Reviewed-on: https://go-review.googlesource.com/c/go/+/472435 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
2023-02-27internal/poll: avoid race between SetDeadline and timer expiry in Plan 9miller
The mutexes added by CL 235820 aren't sufficient to prevent a race when an i/o deadline timer fires just as the deadline is being reset to zero. Consider this possible sequence when goroutine S is clearing the deadline and goroutine T has been started by the timer: 1. S locks the mutex 2. T blocks on the mutex 3. S sets the timedout flag to false 4. S calls Stop on the timer (and fails, because the timer has fired) 5. S unlocks the mutex 6. T locks the mutex 7. T sets the timedout flag to true Now all subsequent I/O will timeout, although the deadline has been cleared. The fix is for the timeout goroutine to skip setting the timedout flag if the timer pointer has been cleared, or reassigned by another SetDeadline operation. Fixes #57114 Change-Id: I4a45d19c3b4b66cdf151dcc3f70536deaa8216a7 Reviewed-on: https://go-review.googlesource.com/c/go/+/470215 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David du Colombier <0intro@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-02-22Revert "internal/poll: drop redundant ENOSYS in CopyFileRange"Ian Lance Taylor
This reverts CL 428555. Reason for revert: It appears that even a newer kernel can get ENOSYS from copy_file_range. Fixes #58592 Change-Id: Ib8dd1be61544f54bf652a99dc0b449109f8f50ed Reviewed-on: https://go-review.googlesource.com/c/go/+/470016 Reviewed-by: Andy Pan <panjf2000@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2023-02-09runtime: fix signature for linked functionsAdin Scannell
These functions are linked using go:linkname, but do not match the original declarations. This change brings these in sync. Change-Id: I16651304c3dba2f9897c2c42e30555d2f7805c2a Reviewed-on: https://go-review.googlesource.com/c/go/+/466615 Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Michael Pratt <mpratt@google.com>
2023-02-02internal/poll: use atomic.Bool in DupCloseOnExecTobias Klauser
Invert the meaning of the var to make use of the zero value. Change-Id: If18db09896a67cb37cb3fe7dc0fb3493c6050a87 Reviewed-on: https://go-review.googlesource.com/c/go/+/463847 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-01-30internal/poll: don't queue port completion entry for udp on windowsqmuntal
This CL sets the FILE_SKIP_COMPLETION_PORT_ON_SUCCESS notification mode for all udp and tcp networks. When SetFileCompletionNotificationModes was implemented, back in go 1.2 [1], it was not possible to enable this mode on udp connections because it is buggy on Windows 7 and earlier. The bug was fixed on Windows 8. We can safely enable this mode now, since go 1.21 will require Windows 10 or higher. While here, I noticed that this mode is only enabled for tcp, but not for tcp4 nor tcp6. I don't think this restriction makes sense, so I'm lifting it. The performance gains are relevant: name old time/op new time/op delta ReadWriteMsgUDPAddrPort-12 13.3µs ± 4% 11.2µs ± 8% -15.90% (p=0.000 n=10+9) WriteToReadFromUDP-12 14.5µs ±18% 11.4µs ± 4% -21.35% (p=0.000 n=10+9) WriteToReadFromUDPAddrPort-12 13.4µs ± 3% 11.0µs ± 2% -18.00% (p=0.000 n=10+9) [1] https://codereview.appspot.com/12409044 Change-Id: Idf41c35898beceac39d21decb47910f7d8ac247b Reviewed-on: https://go-review.googlesource.com/c/go/+/463839 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-12-16syscall, internal/poll: fall back to accept on linux-armIan Lance Taylor
Our minimum Linux version is 2.6.32, and the accept4 system call was introduced in 2.6.28, so we use accept4 everywhere. Unfortunately, it turns out that the accept4 system call was only added to linux-arm in 2.6.36, so for linux-arm only we need to try the accept4 system call and then fall back to accept if it doesn't work. The code we use on linux-arm is the code we used in Go 1.17. On non-arm platforms we continue using the simpler code introduced in Go 1.18. Adding accept4 to the ARM Linux kernel was: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=21d93e2e29722d7832f61cc56d73fb953ee6578e Fixes #57333 Change-Id: I6680cb54dd4d3514a6887dda8906e6708c64459d Reviewed-on: https://go-review.googlesource.com/c/go/+/457995 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-14os,syscall: File.Stat to use file handle for directories on Windowsqmuntal
Updates syscall.Open to support opening directories via CreateFileW. CreateFileW handles are more versatile than FindFirstFile handles. They can be used in Win32 APIs like GetFileInformationByHandle and SetFilePointerEx, which are needed by some Go APIs. Fixes #52747 Fixes #36019 Change-Id: I26a00cef9844fb4abeeb18d2f9d854162a146651 Reviewed-on: https://go-review.googlesource.com/c/go/+/405275 Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Patrik Nyblom <pnyb@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-09io: correctly process result of sendfile(2) when src returns 0 bytesDaulet Zhanguzin
Fixes #53658. io.Copy() uses sendfile(2) to avoid allocating extra buffers when src is a file and dst is a TCPConn. However if src returns no bytes current logic treats it as failure and falls back to copying via user space. The following is a benchmark that illustrates the bug. Benchmark: https://go.dev/play/p/zgZwpjUatSq Before: BenchmarkCopy-16 541006 2137 ns/op 4077 B/op 0 allocs/op After: BenchmarkCopy-16 490383 2365 ns/op 174 B/op 8 allocs/op Change-Id: I703376d53b20e080c6204a73c96867cce16b24cf GitHub-Last-Rev: 3a50be4f169683bf9caea32892c66619a66ad21a GitHub-Pull-Request: golang/go#53659 Reviewed-on: https://go-review.googlesource.com/c/go/+/415834 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-10-08os: use poll.fdMutex for Plan 9 filesIan Lance Taylor
This permits us to safely support concurrent access to files on Plan 9. Concurrent access was already safe on other systems. This does introduce a change: if one goroutine calls a blocking read on a pipe, and another goroutine closes the pipe, then before this CL the close would occur. Now the close will be delayed until the blocking read completes. Also add tests that concurrent I/O and Close on a pipe are OK. For #50436 For #56043 Change-Id: I969c869ea3b8c5c2f2ef319e441a56a3c64e7bf5 Reviewed-on: https://go-review.googlesource.com/c/go/+/438347 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David du Colombier <0intro@gmail.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2022-10-07internal/poll, internal/syscall/unix, syscall: move writev definition for ↵Tobias Klauser
solaris Move the writev definition for solaris from package internal/syscall/unix to package syscall. This corresponds to where writev is defined on aix, darwin and openbsd as well and is go:linkname'ed from internal/poll. This also allows updating the generated wrappers more easily if needed. Change-Id: I671ed8232d25319f8e63f549f786d77a17602148 Reviewed-on: https://go-review.googlesource.com/c/go/+/436597 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2022-10-07internal/poll, net, syscall: enable writev on aixTobias Klauser
aix supports iovec read/write, see https://www.ibm.com/docs/en/aix/7.2?topic=w-write-writex-write64x-writev-writevx-ewrite-ewritev-pwrite-pwritev-subroutine Define an unexported writev wrapper in package syscall (like on openbsd and darwin) and linkname it from internal/poll. Change-Id: I8f9695ceac72ae861afa3692207c154d86d4e690 Reviewed-on: https://go-review.googlesource.com/c/go/+/435260 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2022-09-30internal: fix a few function names on commentscui fliter
Change-Id: I53169e386b8c789b092de348fa891fe50e11c2ef GitHub-Last-Rev: 75232393b4ba415bddc731f15550d7094ccfd953 GitHub-Pull-Request: golang/go#55965 Reviewed-on: https://go-review.googlesource.com/c/go/+/436883 Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-09internal/poll, syscall: convert writev to direct libc call on openbsd ↵Tobias Klauser
(except mips64) Add and use a writev libc wrapper instead of using syscall(2). Updates golang/go#36435 Change-Id: I3c67665388ac276d9ef36868e368e91efb92800e Reviewed-on: https://go-review.googlesource.com/c/go/+/428776 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Joel Sing <joel@sing.id.au> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-09-09internal/poll: drop redundant ENOSYS in CopyFileRangeAndy Pan
Update CL 425881 and CL 428396 I browsed the source code related to copy_file_range in the kernel and found that the latest kernel may still return EXDEV errors in copy_file_range(2) due to certain cases, for details see: https://elixir.bootlin.com/linux/v5.19.7/source/fs/read_write.c#L1559, https://elixir.bootlin.com/linux/v5.19.7/source/fs/read_write.c#L1479, and https://elixir.bootlin.com/linux/v5.19.7/source/fs/read_write.c#L1439. Therefore, the EXDEV still needs to be kept, but the ENOSYS error can be safely removed. Change-Id: I47026b8dd33f7ffc4de1306af6b67c7b4d2062d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/428555 Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Andy Pan <panjf2000@gmail.com>
2022-09-06internal/poll, internal/syscall/unix, net: enable writev on solarisTobias Klauser
The writev syscall is available since at least Solaris 11.3. Reuse the existing illumos writev wrapper on solaris to implement internal/poll.writev for net.(*netFD).writeBuffers. Change-Id: I23adc3bb4637740c72bfb61bfa9697b432dfe3db Reviewed-on: https://go-review.googlesource.com/c/go/+/427714 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-09-06Revert "internal/poll: drop redundant ENOSYS and EXDEV error checks in ↵Daniel Martí
CopyFileRange()" This reverts https://go.dev/cl/425881. Reason for revert: broke make.bash on linux/amd64 with Linux 5.19.6. [...] Building Go toolchain2 using go_bootstrap and Go toolchain1. go install internal/unsafeheader: copying /tmp/go-build4206185186/b007/_pkg_.a to /home/mvdan/tip/pkg/linux_amd64/internal/unsafeheader.a: write /home/mvdan/tip/pkg/linux_amd64/internal/unsafeheader.a: copy_file_range: invalid cross-device link go install internal/goarch: copying /tmp/go-build4206185186/b006/_pkg_.a to /home/mvdan/tip/pkg/linux_amd64/internal/goarch.a: write /home/mvdan/tip/pkg/linux_amd64/internal/goarch.a: copy_file_range: invalid cross-device link [...] Change-Id: I793856935d4315a870c2d31da46be00cc342b5f8 Reviewed-on: https://go-review.googlesource.com/c/go/+/428396 Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: hopehook <hopehook@golangcn.org> Reviewed-by: Andy Pan <panjf2000@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2022-09-05internal/poll: drop redundant ENOSYS and EXDEV error checks in CopyFileRange()Andy Pan
The initial CL 229101 didn't limit the kernel version, but relies on error checking to ensure the kernel version >= 4.5 or >= 5.3 when it's calling copy_file_range(2) to copy data across file systems. Since we have now put the kernel version checking at the beginning of the function, introduced by CL 268338, which returns early instead of going forward to the code behind when the kernel verion is older than 5.3, therefore, those subsequent related error checks are no longer needed. Change-Id: Ifc4a530723e21f0bde91d6420cde9cb676081922 Reviewed-on: https://go-review.googlesource.com/c/go/+/425881 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: hopehook <hopehook@golangcn.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-09-03internal/syscall/unix: consolidate kernelVersion implementationsKir Kolyshkin
Currently, there are 3 functions returning Linux kernel version numbers. Two of them are identical: - in net, initially added by commit 0a9dd47dd817904e; - in internal/poll, initially added by commit 1c7650aa93bd53; (both were later fixed by commit 66c02645062561a). The third one is a more complex, regexp-based implementation in runtime/pprof, which is only used for a test. Instead of adding one more, let's consolidate existing ones. Remove the complex implementation, and move the simple one into internal/syscall/unix. Use it from all the three places mentioned above. Change-Id: I4a34d9ca47257743c16def30e4dd634e36056091 Reviewed-on: https://go-review.googlesource.com/c/go/+/424896 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-31internal/poll, internal/syscall/unix, net, runtime: convert openbsd (except ↵Tobias Klauser
mips64) to direct libc calls Call libc wrappers directly rather than calling using syscall(2). Updates golang/go#36435 Change-Id: I40be410c7472f7d89cbec2ebdc7c841c7726ca4a Reviewed-on: https://go-review.googlesource.com/c/go/+/425637 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Joel Sing <joel@sing.id.au>
2022-08-29internal/poll: use sync.Once instead to guard CopyFileRange() with kernel 5.3Andy Pan
The existing implementation creates more branches with more states: -1, 0, 1, which makes it not very intuitive to understand, let's use sync.Once and boolean instead to make it more straightforward. Change-Id: I05766e5fdf7dba37d6565f84d3db4373f9342fe5 Reviewed-on: https://go-review.googlesource.com/c/go/+/425880 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-08-26internal/poll: optimize the maximum amount of bytes that can be transferred ↵Andy Pan
by one splice(2) call Fixes #40222 name old time/op new time/op delta Splice/tcp-to-tcp/1024-4 5.16µs ± 1% 5.17µs ± 4% ~ (p=0.481 n=10+10) Splice/tcp-to-tcp/2048-4 5.46µs ± 2% 5.48µs ± 2% ~ (p=0.617 n=10+10) Splice/tcp-to-tcp/4096-4 6.07µs ± 3% 6.09µs ± 5% ~ (p=0.927 n=10+10) Splice/tcp-to-tcp/8192-4 7.07µs ± 5% 7.16µs ± 3% ~ (p=0.324 n=10+10) Splice/tcp-to-tcp/16384-4 8.82µs ±10% 8.83µs ±11% ~ (p=1.000 n=10+10) Splice/tcp-to-tcp/32768-4 12.3µs ±12% 12.7µs ± 4% ~ (p=0.268 n=10+9) Splice/tcp-to-tcp/65536-4 22.1µs ± 3% 22.0µs ± 3% ~ (p=0.912 n=10+10) Splice/tcp-to-tcp/131072-4 40.0µs ± 4% 39.9µs ± 4% ~ (p=1.000 n=9+8) Splice/tcp-to-tcp/262144-4 69.1µs ± 3% 67.9µs ± 2% -1.67% (p=0.010 n=9+10) Splice/tcp-to-tcp/524288-4 128µs ± 3% 124µs ± 2% -2.67% (p=0.001 n=9+10) Splice/tcp-to-tcp/1048576-4 242µs ± 3% 242µs ± 2% ~ (p=0.912 n=10+10) Splice/unix-to-tcp/1024-4 1.97µs ± 3% 1.96µs ± 2% ~ (p=0.342 n=10+10) Splice/unix-to-tcp/2048-4 2.19µs ± 2% 2.21µs ± 2% ~ (p=0.150 n=9+10) Splice/unix-to-tcp/4096-4 2.52µs ± 5% 2.50µs ± 1% ~ (p=0.393 n=10+10) Splice/unix-to-tcp/8192-4 3.27µs ± 4% 3.24µs ± 7% ~ (p=0.968 n=9+10) Splice/unix-to-tcp/16384-4 4.68µs ± 9% 4.79µs ± 8% ~ (p=0.739 n=10+10) Splice/unix-to-tcp/32768-4 7.82µs ±12% 7.76µs ±12% ~ (p=0.912 n=10+10) Splice/unix-to-tcp/65536-4 17.9µs ± 3% 17.3µs ±10% ~ (p=0.661 n=9+10) Splice/unix-to-tcp/131072-4 35.9µs ± 1% 31.3µs ± 4% -12.88% (p=0.000 n=10+9) Splice/unix-to-tcp/262144-4 72.4µs ± 3% 55.4µs ± 2% -23.55% (p=0.000 n=10+10) Splice/unix-to-tcp/524288-4 146µs ± 3% 113µs ± 1% -22.87% (p=0.000 n=9+9) Splice/unix-to-tcp/1048576-4 288µs ± 3% 223µs ± 3% -22.49% (p=0.000 n=10+9) name old speed new speed delta Splice/tcp-to-tcp/1024-4 198MB/s ± 1% 198MB/s ± 4% ~ (p=0.481 n=10+10) Splice/tcp-to-tcp/2048-4 375MB/s ± 2% 374MB/s ± 2% ~ (p=0.631 n=10+10) Splice/tcp-to-tcp/4096-4 674MB/s ± 3% 673MB/s ± 5% ~ (p=0.912 n=10+10) Splice/tcp-to-tcp/8192-4 1.16GB/s ± 6% 1.15GB/s ± 3% ~ (p=0.315 n=10+10) Splice/tcp-to-tcp/16384-4 1.86GB/s ±10% 1.84GB/s ±13% ~ (p=0.720 n=10+9) Splice/tcp-to-tcp/32768-4 2.68GB/s ±13% 2.57GB/s ± 7% ~ (p=0.165 n=10+10) Splice/tcp-to-tcp/65536-4 2.97GB/s ± 3% 2.98GB/s ± 3% ~ (p=0.912 n=10+10) Splice/tcp-to-tcp/131072-4 3.28GB/s ± 4% 3.29GB/s ± 4% ~ (p=1.000 n=9+8) Splice/tcp-to-tcp/262144-4 3.80GB/s ± 3% 3.86GB/s ± 2% +1.70% (p=0.010 n=9+10) Splice/tcp-to-tcp/524288-4 4.10GB/s ± 3% 4.21GB/s ± 2% +2.74% (p=0.001 n=9+10) Splice/tcp-to-tcp/1048576-4 4.34GB/s ± 3% 4.33GB/s ± 2% ~ (p=0.912 n=10+10) Splice/unix-to-tcp/1024-4 519MB/s ± 3% 523MB/s ± 2% ~ (p=0.353 n=10+10) Splice/unix-to-tcp/2048-4 934MB/s ± 2% 926MB/s ± 2% ~ (p=0.156 n=9+10) Splice/unix-to-tcp/4096-4 1.63GB/s ± 5% 1.64GB/s ± 1% ~ (p=0.393 n=10+10) Splice/unix-to-tcp/8192-4 2.51GB/s ± 3% 2.53GB/s ± 7% ~ (p=0.968 n=9+10) Splice/unix-to-tcp/16384-4 3.52GB/s ± 8% 3.43GB/s ± 8% ~ (p=0.739 n=10+10) Splice/unix-to-tcp/32768-4 4.21GB/s ±14% 4.24GB/s ±13% ~ (p=0.912 n=10+10) Splice/unix-to-tcp/65536-4 3.65GB/s ± 5% 3.81GB/s ±11% ~ (p=0.436 n=10+10) Splice/unix-to-tcp/131072-4 3.65GB/s ± 1% 4.19GB/s ± 4% +14.81% (p=0.000 n=10+9) Splice/unix-to-tcp/262144-4 3.62GB/s ± 3% 4.73GB/s ± 2% +30.78% (p=0.000 n=10+10) Splice/unix-to-tcp/524288-4 3.59GB/s ± 3% 4.66GB/s ± 1% +29.64% (p=0.000 n=9+9) Splice/unix-to-tcp/1048576-4 3.65GB/s ± 3% 4.70GB/s ± 3% +29.01% (p=0.000 n=10+9) name old alloc/op new alloc/op delta Splice/tcp-to-tcp/1024-4 0.00B 0.00B ~ (all equal) Splice/tcp-to-tcp/2048-4 0.00B 0.00B ~ (all equal) Splice/tcp-to-tcp/4096-4 0.00B 0.00B ~ (all equal) Splice/tcp-to-tcp/8192-4 0.00B 0.00B ~ (all equal) Splice/tcp-to-tcp/16384-4 0.00B 0.00B ~ (all equal) Splice/tcp-to-tcp/32768-4 0.00B 0.00B ~ (all equal) Splice/tcp-to-tcp/65536-4 0.00B 0.00B ~ (all equal) Splice/tcp-to-tcp/131072-4 0.00B 0.00B ~ (all equal) Splice/tcp-to-tcp/262144-4 0.00B 0.00B ~ (all equal) Splice/tcp-to-tcp/524288-4 0.00B 0.00B ~ (all equal) Splice/tcp-to-tcp/1048576-4 0.00B 0.00B ~ (all equal) Splice/unix-to-tcp/1024-4 0.00B 0.00B ~ (all equal) Splice/unix-to-tcp/2048-4 0.00B 0.00B ~ (all equal) Splice/unix-to-tcp/4096-4 0.00B 0.00B ~ (all equal) Splice/unix-to-tcp/8192-4 0.00B 0.00B ~ (all equal) Splice/unix-to-tcp/16384-4 0.00B 0.00B ~ (all equal) Splice/unix-to-tcp/32768-4 0.00B 0.00B ~ (all equal) Splice/unix-to-tcp/65536-4 0.00B 0.00B ~ (all equal) Splice/unix-to-tcp/131072-4 0.00B 0.00B ~ (all equal) Splice/unix-to-tcp/262144-4 0.00B 0.00B ~ (all equal) Splice/unix-to-tcp/524288-4 0.00B 0.00B ~ (all equal) Splice/unix-to-tcp/1048576-4 0.00B 0.00B ~ (all equal) name old allocs/op new allocs/op delta Splice/tcp-to-tcp/1024-4 0.00 0.00 ~ (all equal) Splice/tcp-to-tcp/2048-4 0.00 0.00 ~ (all equal) Splice/tcp-to-tcp/4096-4 0.00 0.00 ~ (all equal) Splice/tcp-to-tcp/8192-4 0.00 0.00 ~ (all equal) Splice/tcp-to-tcp/16384-4 0.00 0.00 ~ (all equal) Splice/tcp-to-tcp/32768-4 0.00 0.00 ~ (all equal) Splice/tcp-to-tcp/65536-4 0.00 0.00 ~ (all equal) Splice/tcp-to-tcp/131072-4 0.00 0.00 ~ (all equal) Splice/tcp-to-tcp/262144-4 0.00 0.00 ~ (all equal) Splice/tcp-to-tcp/524288-4 0.00 0.00 ~ (all equal) Splice/tcp-to-tcp/1048576-4 0.00 0.00 ~ (all equal) Splice/unix-to-tcp/1024-4 0.00 0.00 ~ (all equal) Splice/unix-to-tcp/2048-4 0.00 0.00 ~ (all equal) Splice/unix-to-tcp/4096-4 0.00 0.00 ~ (all equal) Splice/unix-to-tcp/8192-4 0.00 0.00 ~ (all equal) Splice/unix-to-tcp/16384-4 0.00 0.00 ~ (all equal) Splice/unix-to-tcp/32768-4 0.00 0.00 ~ (all equal) Splice/unix-to-tcp/65536-4 0.00 0.00 ~ (all equal) Splice/unix-to-tcp/131072-4 0.00 0.00 ~ (all equal) Splice/unix-to-tcp/262144-4 0.00 0.00 ~ (all equal) Splice/unix-to-tcp/524288-4 0.00 0.00 ~ (all equal) Splice/unix-to-tcp/1048576-4 0.00 0.00 ~ (all equal) Change-Id: I899c1fdcb3f7b9997faf2b0d2336016a3f1fd3ea Reviewed-on: https://go-review.googlesource.com/c/go/+/425051 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-08-22internal/poll: rely on utf8.AppendRuneJoe Tsai
This is both simpler and more performant. Change-Id: I398de29230e578fb7caf1765df7b8fe84d4e8876 Reviewed-on: https://go-review.googlesource.com/c/go/+/412336 Run-TryBot: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-08-18internal/poll: remove fallback path in acceptTobias Klauser
Support for operating system versions requiring the fallback to CloseOnExec/SetNonblock was dropped from recent Go versions. The minimum Linux kernel version is 2.6.32 as of Go 1.18. FreeBSD 10 is no longer supported as of Go 1.13. Follows a similar change for net.sysSocket in CL 403634 and syscall.Socket in CL 422374. For #45964 Change-Id: I60848415742a1d8204e1fda585462ff35ad6722f Reviewed-on: https://go-review.googlesource.com/c/go/+/422375 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-08-18internal/poll: remove detection of buggy splice on old Linux versionsTobias Klauser
The splice syscall is buggy prior to Linux 2.6.29. CL 113999 added a workaround to detect buggy versions and disable use of splice for these. As of Go 1.18 the minumum Linux version is 2.6.32. Thus, a non-buggy implementation of the splice syscall can be assumed. For #45964 Fixes #54505 Change-Id: Ied3a3334da7a3f7fa1280b7c5b1dfb9030219336 Reviewed-on: https://go-review.googlesource.com/c/go/+/422979 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-08-12all: replace hand-rolled atomicBool types with atomic.BoolLudi Rehak
Two packages construct atomic booleans from atomic integers. Replace these implementations with the new atomic.Bool type. Indeed, these packages were the impetus for the new atomic.Bool type, having demonstrated a need to access boolean values atomically. Change-Id: I6a0314f8e7d660984a6daf36a62ed05a0eb74b2f Reviewed-on: https://go-review.googlesource.com/c/go/+/411400 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2022-05-03internal/poll, net, syscall: use accept4 on solarisTobias Klauser
Solaris supports accept4 since version 11.4, see https://docs.oracle.com/cd/E88353_01/html/E37843/accept4-3c.html Use it in internal/poll.accept like on other platforms. Change-Id: I3d9830a85e93bbbed60486247c2f91abc646371f Reviewed-on: https://go-review.googlesource.com/c/go/+/403394 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-05-02internal/poll: clear completed Buffers to permit earlier collectionBaokun Lee
Updates #45163 Change-Id: I73a6f22715550e0e8b83fbd3ebec72ef019f153f Reviewed-on: https://go-review.googlesource.com/c/go/+/373374 Run-TryBot: Lee Baokun <bk@golangcn.org> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-05all: separate doc comment from //go: directivesRuss Cox
A future change to gofmt will rewrite // Doc comment. //go:foo to // Doc comment. // //go:foo Apply that change preemptively to all comments (not necessarily just doc comments). For #51082. Change-Id: Iffe0285418d1e79d34526af3520b415a12203ca9 Reviewed-on: https://go-review.googlesource.com/c/go/+/384260 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-29all: use new "unix" build tag where appropriateIan Lance Taylor
For #20322 For #51572 Change-Id: Id0b4799d097d01128e98ba4cc0092298357bca45 Reviewed-on: https://go-review.googlesource.com/c/go/+/389935 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-12-13all: gofmt -w -r 'interface{} -> any' srcRuss Cox
And then revert the bootstrap cmd directories and certain testdata. And adjust tests as needed. Not reverting the changes in std that are bootstrapped, because some of those changes would appear in API docs, and we want to use any consistently. Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories when preparing the bootstrap copy. A few files changed as a result of running gofmt -w not because of interface{} -> any but because they hadn't been updated for the new //go:build lines. Fixes #49884. Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09 Reviewed-on: https://go-review.googlesource.com/c/go/+/368254 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>