aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/malloc.goc
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2012-11-07 12:48:58 +0400
committerDmitriy Vyukov <dvyukov@google.com>2012-11-07 12:48:58 +0400
commit1a19f01a683f8c62b7bd5f843a2e1b7ed6449542 (patch)
tree3d07d992836a4d8d298ba7ed9cad25bfd1e9098e /src/pkg/runtime/malloc.goc
parenta3a7244779066ba639e9c61d4b351800a9cb77f6 (diff)
downloadgo-1a19f01a683f8c62b7bd5f843a2e1b7ed6449542.tar.xz
runtime/race: lazily allocate shadow memory
Currently race detector runtime maps shadow memory eagerly at process startup. It works poorly on Windows, because Windows requires reservation in swap file (especially problematic if several Go program runs at the same, each consuming GBs of memory). With this change race detector maps shadow memory lazily, so Go runtime must notify about all new heap memory. It will help with Windows port, but also eliminates scary 16TB virtual mememory consumption in top output (which sometimes confuses some monitoring scripts). R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6811085
Diffstat (limited to 'src/pkg/runtime/malloc.goc')
-rw-r--r--src/pkg/runtime/malloc.goc4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc
index f8aa1c949e..a96372451c 100644
--- a/src/pkg/runtime/malloc.goc
+++ b/src/pkg/runtime/malloc.goc
@@ -434,6 +434,8 @@ runtime·MHeap_SysAlloc(MHeap *h, uintptr n)
runtime·SysMap(p, n);
h->arena_used += n;
runtime·MHeap_MapBits(h);
+ if(raceenabled)
+ runtime·racemapshadow(p, n);
return p;
}
@@ -460,6 +462,8 @@ runtime·MHeap_SysAlloc(MHeap *h, uintptr n)
if(h->arena_used > h->arena_end)
h->arena_end = h->arena_used;
runtime·MHeap_MapBits(h);
+ if(raceenabled)
+ runtime·racemapshadow(p, n);
}
return p;