Skip to content

Commit

Permalink
Fix perf benchmarks (#948)
Browse files Browse the repository at this point in the history
Motivation:

In #922 we adopted some changes from NIO HTTP/2: our handlers now speak
in terms of `HTTP2Frame.FramePayload` rather than `HTTP2Frame`. We
forgot to update our benchmarks at that time.

Modifications:

- Speak in `HTTP2Frame.FramePayload`s in embedded client benchmarks
- Fix up a couple of typos in benchmark names

Result:

Benchmarks work.
  • Loading branch information
glbrntt authored Aug 24, 2020
1 parent 8b5d7d9 commit 4ee6305
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class EmbeddedClientThroughput: Benchmark {

// Read out the request frames.
var requestFrames = 0
while let _ = try channel.readOutbound(as: HTTP2Frame.self) {
while let _ = try channel.readOutbound(as: HTTP2Frame.FramePayload.self) {
requestFrames += 1
}
precondition(requestFrames == 3) // headers, data, empty data (end-stream)
Expand All @@ -114,15 +114,13 @@ class EmbeddedClientThroughput: Benchmark {
":status": "200",
"content-type": "application/grpc+proto",
]
let headerFrame = HTTP2Frame(
streamID: .init(1),
payload: .headers(.init(headers: responseHeaders))
)

let headerFrame = HTTP2Frame.FramePayload.headers(.init(headers: responseHeaders))
try channel.writeInbound(headerFrame)

// The response data.
for chunk in self.responseDataChunks {
let frame = HTTP2Frame(streamID: 1, payload: .data(.init(data: .byteBuffer(chunk))))
let frame = HTTP2Frame.FramePayload.data(.init(data: .byteBuffer(chunk)))
try channel.writeInbound(frame)
}

Expand All @@ -131,10 +129,7 @@ class EmbeddedClientThroughput: Benchmark {
"grpc-status": "0",
"grpc-message": "ok",
]
let trailersFrame = HTTP2Frame(
streamID: .init(1),
payload: .headers(.init(headers: responseTrailers))
)
let trailersFrame = HTTP2Frame.FramePayload.headers(.init(headers: responseTrailers))
try channel.writeInbound(trailersFrame)

// And read them back out.
Expand Down
4 changes: 2 additions & 2 deletions Sources/GRPCPerformanceTests/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ func runBenchmarks(spec: TestSpec) {
)

measureAndPrint(
description: "embedded_client_unary_10k_large_requests",
description: "embedded_client_unary_1k_large_requests",
benchmark: EmbeddedClientThroughput(requests: 1000, text: largeRequest),
spec: spec
)

measureAndPrint(
description: "embedded_client_unary_10k_large_requests_1k_frames",
description: "embedded_client_unary_1k_large_requests_1k_frames",
benchmark: EmbeddedClientThroughput(
requests: 1000,
text: largeRequest,
Expand Down

0 comments on commit 4ee6305

Please sign in to comment.