From 4d34d081f1c12f3256a31ddae95073cc1f1e9c2e Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Fri, 17 Feb 2017 13:06:34 +0100 Subject: [PATCH] reduce default pool size for non x86 platform to 5MB. --- common/buf/buffer_pool.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common/buf/buffer_pool.go b/common/buf/buffer_pool.go index d64fe54b..dcb1ff43 100644 --- a/common/buf/buffer_pool.go +++ b/common/buf/buffer_pool.go @@ -2,6 +2,7 @@ package buf import ( "os" + "runtime" "strconv" "sync" ) @@ -107,8 +108,17 @@ var ( smallPool = NewSyncPool(SizeSmall) ) +func getDefaultPoolSize() uint32 { + switch runtime.GOARCH { + case "amd64", "386": + return 20 + default: + return 5 + } +} + func init() { - var size uint32 = 20 + var size uint32 = getDefaultPoolSize() sizeStr := os.Getenv(poolSizeEnvKey) if len(sizeStr) > 0 { customSize, err := strconv.ParseUint(sizeStr, 10, 32)