Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix perf benchmarks #948

Merged
merged 1 commit into from
Aug 24, 2020
Merged
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
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