Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions http2/frame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1258,3 +1258,20 @@ func TestSettingsDuplicates(t *testing.T) {
}

}

func BenchmarkParseDataFrames(b *testing.B) {
fr, _ := testFramer()
fr.SetReuseFrames()
payload := []byte("foo")
for i := 0; i < b.N; i++ {
parseDataFrame(fr.frameCache, FrameHeader{StreamID: 3}, func(s string) {}, payload)
}
}

func BenchmarkParseDataFramesWithoutReuse(b *testing.B) {
fr, _ := testFramer()
payload := []byte("foo")
for i := 0; i < b.N; i++ {
parseDataFrame(fr.frameCache, FrameHeader{StreamID: 3}, func(s string) {}, payload)
}
}
1 change: 1 addition & 0 deletions http2/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ func (s *Server) serveConn(c net.Conn, opts *ServeConnOpts, newf func(*serverCon
sc.hpackEncoder.SetMaxDynamicTableSizeLimit(s.maxEncoderHeaderTableSize())

fr := NewFramer(sc.bw, c)
fr.SetReuseFrames()
if s.CountError != nil {
fr.countError = s.CountError
}
Expand Down
1 change: 1 addition & 0 deletions http2/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
})
cc.br = bufio.NewReader(c)
cc.fr = NewFramer(cc.bw, cc.br)
cc.fr.SetReuseFrames()
if t.maxFrameReadSize() != 0 {
cc.fr.SetMaxReadFrameSize(t.maxFrameReadSize())
}
Expand Down