Open
Description
This is an alternative to #15735.
When a slice is constructed (make([]foo, N)
), the Go runtime could avoid allocating the backing array until something actually tries to read or write to the slice. In most cases, the slice is used immediately, so this has little effect, but when used with a blocking implemention of io.Readable.Read
, the internal call to pollDesc.waitRead()
delays the first use of the slice until after the wait. This would improve the memory efficiency of Go socket servers with many blocked sockets (if they are written in a particular style and the garbage collector is working well).
This is not a language change, although it might influence coders to use different slice creation strategies.