diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2013-05-28 11:14:39 +0400 |
|---|---|---|
| committer | Dmitriy Vyukov <dvyukov@google.com> | 2013-05-28 11:14:39 +0400 |
| commit | 828c68f8d80a642d89cc17e04aeb0116c8bce4ae (patch) | |
| tree | f69bcf2729ba62d136c35d3c3ebbdb1af1cd4a56 /src/pkg/runtime/malloc.goc | |
| parent | 5166013f75a7dbab53482292f99c3b6c26cddd0b (diff) | |
| download | go-828c68f8d80a642d89cc17e04aeb0116c8bce4ae.tar.xz | |
undo CL 9805043 / 776aba85ece8
multiple failures on amd64
««« original CL description
runtime: introduce helper persistentalloc() function
It is a caching wrapper around SysAlloc() that can allocate small chunks.
Use it for symtab allocations. Reduces number of symtab walks from 4 to 3
(reduces buildfuncs time from 10ms to 7.5ms on a large binary,
reduces initial heap size by 680K on the same binary).
Also can be used for type info allocation, itab allocation.
There are also several places in GC where we do the same thing,
they can be changed to use persistentalloc().
Also can be used in FixAlloc, because each instance of FixAlloc allocates
in 128K regions, which is too eager.
R=golang-dev, daniel.morsing, khr
CC=golang-dev
https://golang.org/cl/9805043
»»»
R=golang-dev
CC=golang-dev
https://golang.org/cl/9822043
Diffstat (limited to 'src/pkg/runtime/malloc.goc')
| -rw-r--r-- | src/pkg/runtime/malloc.goc | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc index 47eb005894..516182c1cf 100644 --- a/src/pkg/runtime/malloc.goc +++ b/src/pkg/runtime/malloc.goc @@ -496,53 +496,6 @@ runtime·MHeap_SysAlloc(MHeap *h, uintptr n) return p; } -static struct -{ - Lock; - byte* pos; - byte* end; -} persistent; - -enum -{ - PersistentAllocChunk = 256<<10, - PersistentAllocMaxBlock = 64<<10, // VM reservation granularity is 64K on windows -}; - -// Wrapper around SysAlloc that can allocate small chunks. -// There is no associated free operation. -// Intended for things like function/type/debug-related persistent data. -// If align is 0, uses default align (currently 8). -void* -runtime·persistentalloc(uintptr size, uintptr align) -{ - byte *p; - - if(align) { - if(align&(align-1)) - runtime·throw("persistentalloc: align is now a power of 2"); - if(align > PageSize) - runtime·throw("persistentalloc: align is too large"); - } else - align = 8; - if(size >= PersistentAllocMaxBlock) - return runtime·SysAlloc(size); - runtime·lock(&persistent); - persistent.pos = (byte*)ROUND((uintptr)persistent.pos, align); - if(persistent.pos + size > persistent.end) { - persistent.pos = runtime·SysAlloc(PersistentAllocChunk); - if(persistent.pos == nil) { - runtime·unlock(&persistent); - runtime·throw("runtime: cannot allocate memory"); - } - persistent.end = persistent.pos + PersistentAllocChunk; - } - p = persistent.pos; - persistent.pos += size; - runtime·unlock(&persistent); - return p; -} - static Lock settype_lock; void |
