Skip to content

Commit

Permalink
perf(client): use grpc.SharedBufferPool for grpc.DialOption
Browse files Browse the repository at this point in the history
When a client library parses incoming gRPC messages, it allocates new buffers
frequently. This can result in the creation of a large number of heap objects.
However, gRPC offers an experimental feature called the shared buffer pool that
can be used to address this issue.

This pull request (PR) aims to optimize the gRPC receiving path using the shared
buffer pool. Various experiments have shown that this optimization leads to a
decrease in CPU time of runtime.gcBgMarkWorkers, depending on the workload.

Refs:
- https://pkg.go.dev/google.golang.org/[email protected]/experimental#WithRecvBufferPool
- https://pkg.go.dev/google.golang.org/[email protected]#SharedBufferPool
  • Loading branch information
ijsong committed Feb 25, 2024
1 parent 76484b8 commit 889b990
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/varlog/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/experimental"

"github.com/kakao/varlog/pkg/types"
)
Expand Down Expand Up @@ -48,6 +49,7 @@ func defaultOptions() options {
grpc.MaxCallRecvMsgSize(math.MaxInt32),
grpc.MaxCallSendMsgSize(math.MaxInt32),
),
experimental.WithRecvBufferPool(grpc.NewSharedBufferPool()),

Check warning on line 52 in pkg/varlog/options.go

View check run for this annotation

Codecov / codecov/patch

pkg/varlog/options.go#L52

Added line #L52 was not covered by tests
},
}
}
Expand Down
65 changes: 65 additions & 0 deletions vendor/google.golang.org/grpc/experimental/experimental.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ google.golang.org/grpc/credentials/insecure
google.golang.org/grpc/encoding
google.golang.org/grpc/encoding/gzip
google.golang.org/grpc/encoding/proto
google.golang.org/grpc/experimental
google.golang.org/grpc/grpclog
google.golang.org/grpc/health
google.golang.org/grpc/health/grpc_health_v1
Expand Down

0 comments on commit 889b990

Please sign in to comment.