-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⭐️ benchmark testing for Ranger RPC, GRPC and Twirp (#8)
Signed-off-by: Christoph Hartmann <[email protected]>
- Loading branch information
1 parent
201af8a
commit ffa1f6f
Showing
21 changed files
with
3,700 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
benchmark/cpu.out | ||
benchmark/mem.out | ||
benchmark/trace.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
prep: | ||
command -v protoc-gen-go || go install github.com/golang/protobuf/protoc-gen-go | ||
command -v protoc-gen-go-grpc || go install google.golang.org/grpc/cmd/protoc-gen-go-grpc | ||
command -v protoc-gen-twirp || go install github.com/twitchtv/twirp/protoc-gen-twirp | ||
command -v hey || go install github.com/rakyll/hey | ||
go generate ./twirpbench | ||
go generate ./grpcbench | ||
go generate ./rangerbench | ||
|
||
.PHONY: bench | ||
bench: | ||
# NOTE: if you see too many open files error, set `ulimit -n 10240` on macOS | ||
go test -v -benchmem -benchtime 5s -bench . # -cpuprofile=cpu.out -memprofile=mem.out -trace trace.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
|
||
Tested on M1 macOS | ||
|
||
# Twirp | ||
|
||
``` | ||
=== RUN TestLoad/twrip_http_protobuf_roundtrip | ||
Summary: | ||
Total: 0.0104 secs | ||
Slowest: 0.0066 secs | ||
Fastest: 0.0008 secs | ||
Average: 0.0024 secs | ||
Requests/sec: 19211.2956 | ||
Total data: 33600 bytes | ||
Size/request: 168 bytes | ||
``` | ||
|
||
# Ranger | ||
|
||
``` | ||
=== RUN TestLoad/ranger_http_protobuf_roundtrip | ||
Summary: | ||
Total: 0.1280 secs | ||
Slowest: 0.0871 secs | ||
Fastest: 0.0010 secs | ||
Average: 0.0276 secs | ||
Requests/sec: 1562.8643 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module go.mondoo.com/ranger-rpc/benchmark | ||
|
||
go 1.18 | ||
|
||
require ( | ||
github.com/rakyll/hey v0.1.4 | ||
github.com/twitchtv/twirp v8.1.2+incompatible | ||
go.mondoo.com/ranger-rpc v0.0.0-00010101000000-000000000000 | ||
golang.org/x/net v0.0.0-20220708220712-1185a9018129 | ||
google.golang.org/grpc v1.48.0 | ||
google.golang.org/protobuf v1.28.0 | ||
) | ||
|
||
require ( | ||
github.com/cockroachdb/errors v1.9.0 // indirect | ||
github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f // indirect | ||
github.com/cockroachdb/redact v1.1.3 // indirect | ||
github.com/getsentry/sentry-go v0.13.0 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/kr/pretty v0.3.0 // indirect | ||
github.com/kr/text v0.2.0 // indirect | ||
github.com/mattn/go-colorable v0.1.12 // indirect | ||
github.com/mattn/go-isatty v0.0.14 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/rogpeppe/go-internal v1.8.1 // indirect | ||
github.com/rs/zerolog v1.27.0 // indirect | ||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
google.golang.org/genproto v0.0.0-20220715211116-798f69b842b9 // indirect | ||
) | ||
|
||
replace go.mondoo.com/ranger-rpc => /Users/chris/go/src/go.mondoo.com/ranger-rpc |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package grpcbench | ||
|
||
import ( | ||
fmt "fmt" | ||
"net" | ||
|
||
"go.mondoo.com/ranger-rpc/benchmark/sample" | ||
context "golang.org/x/net/context" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
//go:generate protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative grpcbench.proto | ||
|
||
type BenchmarkServer struct { | ||
UnimplementedBenchmarkServiceServer | ||
} | ||
|
||
func (b *BenchmarkServer) RpcSmall(ctx context.Context, in *SmallQuery) (*SmallResponse, error) { | ||
return &SmallResponse{Id: in.Id, Message: in.Message, Name: in.Name}, nil | ||
} | ||
func (b *BenchmarkServer) RpcEmpty(ctx context.Context, in *Empty) (*DefaultResponse, error) { | ||
return &DefaultResponse{Message: sample.Message}, nil | ||
} | ||
|
||
func Serve(port int) int { | ||
lis, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", port)) | ||
if err != nil { | ||
panic(fmt.Sprintf("GRPC error %v", err)) | ||
} | ||
|
||
s := grpc.NewServer() | ||
RegisterBenchmarkServiceServer(s, &BenchmarkServer{}) | ||
|
||
go func() { | ||
err := s.Serve(lis) | ||
if err != nil { | ||
fmt.Printf("GRPC error %v", err) | ||
} | ||
}() | ||
|
||
return lis.Addr().(*net.TCPAddr).Port | ||
} |
Oops, something went wrong.