Commit c5617807 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

http2: remove method value allocation per read frame

benchmark                        old ns/op     new ns/op     delta
BenchmarkServer_GetRequest-2     269540        259453        -3.74%

benchmark                        old allocs     new allocs     delta
BenchmarkServer_GetRequest-2     25             24             -4.00%

benchmark                        old bytes     new bytes     delta
BenchmarkServer_GetRequest-2     1613          1599          -0.87%

Change-Id: I33609d8fbe2f81e32095fac8b89ddd55592e583f
Reviewed-on: https://go-review.googlesource.com/20998Reviewed-by: 's avatarAndrew Gerrand <adg@golang.org>
parent 4d06dbda
...@@ -598,10 +598,11 @@ type readFrameResult struct { ...@@ -598,10 +598,11 @@ type readFrameResult struct {
// It's run on its own goroutine. // It's run on its own goroutine.
func (sc *serverConn) readFrames() { func (sc *serverConn) readFrames() {
gate := make(gate) gate := make(gate)
gateDone := gate.Done
for { for {
f, err := sc.framer.ReadFrame() f, err := sc.framer.ReadFrame()
select { select {
case sc.readFrameCh <- readFrameResult{f, err, gate.Done}: case sc.readFrameCh <- readFrameResult{f, err, gateDone}:
case <-sc.doneServing: case <-sc.doneServing:
return return
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment