]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: grow heap by 64K instead of 128K
authorDmitriy Vyukov <dvyukov@google.com>
Wed, 9 Jul 2014 13:00:54 +0000 (17:00 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Wed, 9 Jul 2014 13:00:54 +0000 (17:00 +0400)
When we've switched to 8K pages,
heap started to grow by 128K instead of 64K,
because it was implicitly assuming that pages are 4K.
Fix that and make the code more robust.

LGTM=khr
R=golang-codereviews, dave, khr
CC=golang-codereviews, rsc
https://golang.org/cl/106450044

src/pkg/runtime/mheap.c

index 961b32e50468c3cb55048083e19e263241efd40e..2637eb5b00ba49bf1227d3930e300932074b1084 100644 (file)
@@ -310,8 +310,8 @@ MHeap_Grow(MHeap *h, uintptr npage)
        // Ask for a big chunk, to reduce the number of mappings
        // the operating system needs to track; also amortizes
        // the overhead of an operating system mapping.
-       // Allocate a multiple of 64kB (16 pages).
-       npage = (npage+15)&~15;
+       // Allocate a multiple of 64kB.
+       npage = ROUND(npage, (64<<10)/PageSize);
        ask = npage<<PageShift;
        if(ask < HeapAllocChunk)
                ask = HeapAllocChunk;