From f6f2f77142fcf0a4ec317bff6850ffb6ee6f0bb2 Mon Sep 17 00:00:00 2001 From: Dmitriy Vyukov Date: Wed, 6 Aug 2014 01:50:37 +0400 Subject: runtime: cache one GC workbuf in thread-local storage We call scanblock for lots of small root pieces e.g. for every stack frame args and locals area. Every scanblock invocation calls getempty/putempty, which accesses lock-free stack shared among all worker threads. One-element local cache allows most scanblock calls to proceed without accessing the shared stack. LGTM=rsc R=golang-codereviews, rlh CC=golang-codereviews, khr, rsc https://golang.org/cl/121250043 --- src/pkg/runtime/malloc.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/pkg/runtime/malloc.h') diff --git a/src/pkg/runtime/malloc.h b/src/pkg/runtime/malloc.h index 958c540361..810d4ac402 100644 --- a/src/pkg/runtime/malloc.h +++ b/src/pkg/runtime/malloc.h @@ -334,6 +334,8 @@ struct MCache StackFreeList stackcache[NumStackOrders]; + void* gcworkbuf; + // Local allocator stats, flushed during GC. uintptr local_nlookup; // number of pointer lookups uintptr local_largefree; // bytes freed for large objects (>MaxSmallSize) @@ -344,6 +346,7 @@ struct MCache MSpan* runtime·MCache_Refill(MCache *c, int32 sizeclass); void runtime·MCache_ReleaseAll(MCache *c); void runtime·stackcache_clear(MCache *c); +void runtime·gcworkbuffree(void *b); enum { -- cgit v1.3