Skip to content

Commit

Permalink
rpc_util: rename NewsimpleSharedBufferPool to NewSharedBufferPool
Browse files Browse the repository at this point in the history
  • Loading branch information
hueypark committed May 20, 2023
1 parent 8e8f683 commit 96f5a27
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions benchmark/benchmain/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ func makeClient(bf stats.Features) (testgrpc.BenchmarkServiceClient, func()) {
case recvBufferPoolNil:
// Do nothing.
case recvBufferPoolSimple:
opts = append(opts, grpc.WithRecvBufferPool(grpc.NewsimpleSharedBufferPool()))
sopts = append(sopts, grpc.RecvBufferPool(grpc.NewsimpleSharedBufferPool()))
opts = append(opts, grpc.WithRecvBufferPool(grpc.NewSharedBufferPool()))
sopts = append(sopts, grpc.RecvBufferPool(grpc.NewSharedBufferPool()))
default:
logger.Fatalf("Unknown shared recv buffer pool type: %v", bf.RecvBufferPool)
}
Expand Down
2 changes: 1 addition & 1 deletion dialoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ func WithResolvers(rs ...resolver.Builder) DialOption {
// on the application's workload, this could result in reduced memory allocation.
//
// If you are unsure about how to implement a memory pool but want to utilize one,
// begin with grpc.NewsimpleSharedBufferPool.
// begin with grpc.NewSharedBufferPool.
//
// Note: The shared buffer pool feature will not be active if any of the following
// options are used: WithStatsHandler, EnableTracing, or binary logging. In such
Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ func NumStreamWorkers(numServerWorkers uint32) ServerOption {
// on the application's workload, this could result in reduced memory allocation.
//
// If you are unsure about how to implement a memory pool but want to utilize one,
// begin with grpc.NewsimpleSharedBufferPool.
// begin with grpc.NewSharedBufferPool.
//
// Note: The shared buffer pool feature will not be active if any of the following
// options are used: StatsHandler, EnableTracing, or binary logging. In such
Expand Down
8 changes: 4 additions & 4 deletions shared_buffer_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ type SharedBufferPool interface {
Put(*[]byte)
}

// NewsimpleSharedBufferPool creates a new simpleSharedBufferPool with buckets
// NewSharedBufferPool creates a simple SharedBufferPool with buckets
// of different sizes to optimize memory usage. This prevents the pool from
// wasting large amounts of memory, even when handling messages of varying sizes.
//
// # Experimental
//
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
// later release.
func NewsimpleSharedBufferPool() SharedBufferPool {
func NewSharedBufferPool() SharedBufferPool {
return &simpleSharedBufferPool{
pools: [poolArraySize]simpleSharedBufferChildPool{
newBytesPool(level0PoolMaxSize),
Expand Down Expand Up @@ -139,8 +139,8 @@ type fallbackBufferPool struct {

func (p *fallbackBufferPool) Get(size int) []byte {
bs := p.Pool.Get().(*[]byte)
if cap(*bs) < size {
*bs = make([]byte, size)
if cap(*bs) < size {
*bs = make([]byte, size)
return *bs
}

Expand Down
2 changes: 1 addition & 1 deletion shared_buffer_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import "testing"
func (s) TestSharedBufferPool(t *testing.T) {
pools := []SharedBufferPool{
nopBufferPool{},
NewsimpleSharedBufferPool(),
NewSharedBufferPool(),
}

lengths := []int{
Expand Down
4 changes: 2 additions & 2 deletions test/recv_buffer_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func (s) TestRecvBufferPool(t *testing.T) {
},
}
if err := ss.Start(
[]grpc.ServerOption{grpc.RecvBufferPool(grpc.NewsimpleSharedBufferPool())},
grpc.WithRecvBufferPool(grpc.NewsimpleSharedBufferPool()),
[]grpc.ServerOption{grpc.RecvBufferPool(grpc.NewSharedBufferPool())},
grpc.WithRecvBufferPool(grpc.NewSharedBufferPool()),
); err != nil {
t.Fatalf("Error starting endpoint server: %v", err)
}
Expand Down

0 comments on commit 96f5a27

Please sign in to comment.