aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/malloc2.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2014-12-26 18:10:59 -0800
committerKeith Randall <khr@golang.org>2015-01-07 20:13:06 +0000
commit5aae246f1e1c59511a82398d88128e9fc9357107 (patch)
treec57bc6730c496aba5796c36d8a813e04fa0ba67a /src/runtime/malloc2.go
parentce36552083ef281d4c90b2396a56afa039e119b0 (diff)
downloadgo-5aae246f1e1c59511a82398d88128e9fc9357107.tar.xz
runtime: increase number of stack orders to 4
Cache 2KB, 4KB, 8KB, and 16KB stacks. Larger stacks will be allocated directly. There is no point in cacheing 32KB+ stacks as we ask for and return 32KB at a time from the allocator. Note that the minimum stack is 8K on windows/64bit and 4K on windows/32bit and plan9. For these os/arch combinations, the number of stack orders is less so that we have the same maximum cached size. Fixes #9045 Change-Id: Ia4195dd1858fb79fc0e6a91ae29c374d28839e44 Reviewed-on: https://go-review.googlesource.com/2098 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/malloc2.go')
-rw-r--r--src/runtime/malloc2.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/runtime/malloc2.go b/src/runtime/malloc2.go
index 8cdf668214..54321e9c08 100644
--- a/src/runtime/malloc2.go
+++ b/src/runtime/malloc2.go
@@ -117,7 +117,17 @@ const (
// Number of orders that get caching. Order 0 is FixedStack
// and each successive order is twice as large.
- _NumStackOrders = 3
+ // We want to cache 2KB, 4KB, 8KB, and 16KB stacks. Larger stacks
+ // will be allocated directly.
+ // Since FixedStack is different on different systems, we
+ // must vary NumStackOrders to keep the same maximum cached size.
+ // OS | FixedStack | NumStackOrders
+ // -----------------+------------+---------------
+ // linux/darwin/bsd | 2KB | 4
+ // windows/32 | 4KB | 3
+ // windows/64 | 8KB | 2
+ // plan9 | 4KB | 3
+ _NumStackOrders = 4 - ptrSize/4*goos_windows - 1*goos_plan9
// Number of bits in page to span calculations (4k pages).
// On Windows 64-bit we limit the arena to 32GB or 35 bits.