summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/malloc.h
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-03-08 14:15:44 -0800
committerRuss Cox <rsc@golang.org>2010-03-08 14:15:44 -0800
commitc57f712ac1277849f7fc688adcc8033bddaee261 (patch)
tree51deb835a7c08f107efb65482e7966259f1929db /src/pkg/runtime/malloc.h
parentc1e48b818390aa6f064fc36ff8e9f9b3723fe38b (diff)
downloadgolang-c57f712ac1277849f7fc688adcc8033bddaee261.tar.gz
runtime: clock garbage collection on bytes allocated, not pages in use
This keeps fragmentation from delaying garbage collections (and causing more fragmentation). Cuts fresh godoc (with indexes) from 261M to 166M (120M live). Cuts toy wc program from 50M to 8M. Fixes issue 647. R=r, cw CC=golang-dev http://codereview.appspot.com/257041
Diffstat (limited to 'src/pkg/runtime/malloc.h')
-rw-r--r--src/pkg/runtime/malloc.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/pkg/runtime/malloc.h b/src/pkg/runtime/malloc.h
index b9dea2f5e..ae6b70b14 100644
--- a/src/pkg/runtime/malloc.h
+++ b/src/pkg/runtime/malloc.h
@@ -168,12 +168,13 @@ void FixAlloc_Free(FixAlloc *f, void *p);
// Shared with Go: if you edit this structure, also edit extern.go.
struct MStats
{
- uint64 alloc;
- uint64 total_alloc;
+ uint64 alloc; // unprotected (approximate)
+ uint64 total_alloc; // unprotected (approximate)
uint64 sys;
uint64 stacks;
uint64 inuse_pages; // protected by mheap.Lock
uint64 next_gc; // protected by mheap.Lock
+ uint64 heap_alloc; // protected by mheap.Lock
uint64 nlookup; // unprotected (approximate)
uint64 nmalloc; // unprotected (approximate)
uint64 pause_ns;
@@ -225,11 +226,12 @@ struct MCache
{
MCacheList list[NumSizeClasses];
uint64 size;
+ int64 local_alloc; // bytes allocated (or freed) since last lock of heap
};
void* MCache_Alloc(MCache *c, int32 sizeclass, uintptr size, int32 zeroed);
void MCache_Free(MCache *c, void *p, int32 sizeclass, uintptr size);
-
+void MCache_ReleaseAll(MCache *c);
// An MSpan is a run of pages.
enum
@@ -313,8 +315,8 @@ struct MHeap
extern MHeap mheap;
void MHeap_Init(MHeap *h, void *(*allocator)(uintptr));
-MSpan* MHeap_Alloc(MHeap *h, uintptr npage, int32 sizeclass);
-void MHeap_Free(MHeap *h, MSpan *s);
+MSpan* MHeap_Alloc(MHeap *h, uintptr npage, int32 sizeclass, int32 acct);
+void MHeap_Free(MHeap *h, MSpan *s, int32 acct);
MSpan* MHeap_Lookup(MHeap *h, PageID p);
MSpan* MHeap_LookupMaybe(MHeap *h, PageID p);
void MGetSizeClassInfo(int32 sizeclass, int32 *size, int32 *npages, int32 *nobj);