Skip to content

Commit

Permalink
http2: fix benchmarks using common frame read/write functions
Browse files Browse the repository at this point in the history
CL 586249 unified frame read/write functions used by client
and server tests, but inadvertently broke some benchmarks.
Fix those benchmarks.

This mostly restores the previous behavior of the affected
benchmarks (for example, testing only to see that a DATA frame
contains an END_STREAM marker, ignoring the number of bytes
in the frame).

Fixes golang/go#70647

Change-Id: I2b0099c3513ac8754d11c4e37b7d63277a0fb0b1
Reviewed-on: https://go-review.googlesource.com/c/net/+/633055
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Antonio Ojea <aojea@google.com>
  • Loading branch information
neild authored and gopherbot committed Dec 3, 2024
1 parent 4be1253 commit 6e41410
Showing 1 changed file with 15 additions and 35 deletions.
50 changes: 15 additions & 35 deletions http2/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ func newServerTesterWithRealConn(t testing.TB, handler http.HandlerFunc, opts ..

// sync waits for all goroutines to idle.
func (st *serverTester) sync() {
st.group.Wait()
if st.group != nil {
st.group.Wait()
}
}

// advance advances synthetic time by a duration.
Expand Down Expand Up @@ -2896,15 +2898,10 @@ func BenchmarkServerGets(b *testing.B) {
EndStream: true,
EndHeaders: true,
})
st.wantHeaders(wantHeader{
streamID: 1,
endStream: true,
})
st.wantData(wantData{
streamID: 1,
endStream: true,
size: 0,
})
st.wantFrameType(FrameHeaders)
if df := readFrame[*DataFrame](b, st); !df.StreamEnded() {
b.Fatalf("DATA didn't have END_STREAM; got %v", df)
}
}
}

Expand Down Expand Up @@ -2939,15 +2936,10 @@ func BenchmarkServerPosts(b *testing.B) {
EndHeaders: true,
})
st.writeData(id, true, nil)
st.wantHeaders(wantHeader{
streamID: 1,
endStream: false,
})
st.wantData(wantData{
streamID: 1,
endStream: true,
size: 0,
})
st.wantFrameType(FrameHeaders)
if df := readFrame[*DataFrame](b, st); !df.StreamEnded() {
b.Fatalf("DATA didn't have END_STREAM; got %v", df)
}
}
}

Expand Down Expand Up @@ -3289,14 +3281,8 @@ func BenchmarkServer_GetRequest(b *testing.B) {
EndStream: true,
EndHeaders: true,
})
st.wantHeaders(wantHeader{
streamID: streamID,
endStream: false,
})
st.wantData(wantData{
streamID: streamID,
endStream: true,
})
st.wantFrameType(FrameHeaders)
st.wantFrameType(FrameData)
}
}

Expand Down Expand Up @@ -3327,14 +3313,8 @@ func BenchmarkServer_PostRequest(b *testing.B) {
EndHeaders: true,
})
st.writeData(streamID, true, nil)
st.wantHeaders(wantHeader{
streamID: streamID,
endStream: false,
})
st.wantData(wantData{
streamID: streamID,
endStream: true,
})
st.wantFrameType(FrameHeaders)
st.wantFrameType(FrameData)
}
}

Expand Down

0 comments on commit 6e41410

Please sign in to comment.