What version of Go are you using (go version)?
$ go version
1.17.3
Does this issue reproduce with the latest release?
I believe so, but have not yet confirmed.
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
GOARCH="amd64"
GOOS="linux"
What did you do?
I'm running a service that has many http2 clients.
What did you expect to see?
Fewer allocations when reading data from established connections.
What did you see instead?
Around 20-25% of our service's total allocations at times are coming from context.WithCancel calls made by (*tls.Conn).handshakeContext.
It looks like every (*tls.Context).Read call made by http2's ReadFrame is calling c.Handshake which calls through to c.handshakeContext, which begins with a call to context.WithCancel, which allocates.
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
I believe so, but have not yet confirmed.
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
I'm running a service that has many http2 clients.
What did you expect to see?
Fewer allocations when reading data from established connections.
What did you see instead?
Around 20-25% of our service's total allocations at times are coming from
context.WithCancelcalls made by(*tls.Conn).handshakeContext.It looks like every
(*tls.Context).Readcall made by http2'sReadFrameis callingc.Handshakewhich calls through toc.handshakeContext, which begins with a call tocontext.WithCancel, which allocates.