net: useless memory allocation in writeBuffers on Windows #19222
Comments
I'm not sure I understand. You are commenting on the allocation of the |
|
The problem inside net package. |
Anonymous function func(o *operation) error use external variables. |
May be this changes remove allocations:
|
Original commit: e22b5ef |
@MichaelMonashev that sounds reasonable - looks like my own oversight. Would you like to send a change as per https://golang.org/doc/contribute.html ? The change will need a new test to verify that bug is fixed - something similar to TestTCPReadWriteAllocs in net package. Thank you. Alex |
CL https://golang.org/cl/42893 mentions this issue. |
What version of Go are you using (
go version
)?go version go1.8 windows/386
What operating system and processor architecture are you using (
go env
)?set GOARCH=386
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=386
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Temp\Go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_386
set GCCGO=gccgo
set GO386=
set CC=gcc
set GOGCCFLAGS=-m32 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
What did you do?
Call Buffers.WriteTo() many times: https://golang.org/pkg/net/#Buffers.WriteTo
What did you expect to see?
Zero memory allocations.
What did you see instead?
Memory allocation for each call in this line: https://golang.org/src/net/fd_windows.go#L518 .
The text was updated successfully, but these errors were encountered: