@@ -132,6 +132,10 @@ type http2Server struct {
132
132
maxStreamID uint32 // max stream ID ever seen
133
133
134
134
logger * grpclog.PrefixLogger
135
+ // setResetPingStrikes is stored as a closure instead of making this a
136
+ // method on http2Server to avoid a heap allocation when converting a method
137
+ // to a closure for passing to frames objects.
138
+ setResetPingStrikes func ()
135
139
}
136
140
137
141
// NewServerTransport creates a http2 transport with conn and configuration
@@ -266,6 +270,9 @@ func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport,
266
270
initialWindowSize : iwz ,
267
271
bufferPool : config .BufferPool ,
268
272
}
273
+ t .setResetPingStrikes = func () {
274
+ atomic .StoreUint32 (& t .resetPingStrikes , 1 )
275
+ }
269
276
var czSecurity credentials.ChannelzSecurityValue
270
277
if au , ok := authInfo .(credentials.ChannelzSecurityInfo ); ok {
271
278
czSecurity = au .GetSecurityValue ()
@@ -1016,10 +1023,6 @@ func (t *http2Server) writeHeader(s *ServerStream, md metadata.MD) error {
1016
1023
return nil
1017
1024
}
1018
1025
1019
- func (t * http2Server ) setResetPingStrikes () {
1020
- atomic .StoreUint32 (& t .resetPingStrikes , 1 )
1021
- }
1022
-
1023
1026
func (t * http2Server ) writeHeaderLocked (s * ServerStream ) error {
1024
1027
// TODO(mmukhi): Benchmark if the performance gets better if count the metadata and other header fields
1025
1028
// first and create a slice of that exact size.
0 commit comments