Commit 9f46efce authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

runtime: print scavenger details when forced with debug.FreeOSMemory

Fixes #5900.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12669043
parent 1f4d58ad
...@@ -412,8 +412,8 @@ scavengelist(MSpan *list, uint64 now, uint64 limit) ...@@ -412,8 +412,8 @@ scavengelist(MSpan *list, uint64 now, uint64 limit)
return sumreleased; return sumreleased;
} }
static uintptr static void
scavenge(uint64 now, uint64 limit) scavenge(int32 k, uint64 now, uint64 limit)
{ {
uint32 i; uint32 i;
uintptr sumreleased; uintptr sumreleased;
...@@ -424,7 +424,14 @@ scavenge(uint64 now, uint64 limit) ...@@ -424,7 +424,14 @@ scavenge(uint64 now, uint64 limit)
for(i=0; i < nelem(h->free); i++) for(i=0; i < nelem(h->free); i++)
sumreleased += scavengelist(&h->free[i], now, limit); sumreleased += scavengelist(&h->free[i], now, limit);
sumreleased += scavengelist(&h->large, now, limit); sumreleased += scavengelist(&h->large, now, limit);
return sumreleased;
if(runtime·debug.gctrace > 0) {
if(sumreleased > 0)
runtime·printf("scvg%d: %D MB released\n", k, (uint64)sumreleased>>20);
runtime·printf("scvg%d: inuse: %D, idle: %D, sys: %D, released: %D, consumed: %D (MB)\n",
k, mstats.heap_inuse>>20, mstats.heap_idle>>20, mstats.heap_sys>>20,
mstats.heap_released>>20, (mstats.heap_sys - mstats.heap_released)>>20);
}
} }
static FuncVal forcegchelperv = {(void(*)(void))forcegchelper}; static FuncVal forcegchelperv = {(void(*)(void))forcegchelper};
...@@ -437,8 +444,7 @@ runtime·MHeap_Scavenger(void) ...@@ -437,8 +444,7 @@ runtime·MHeap_Scavenger(void)
{ {
MHeap *h; MHeap *h;
uint64 tick, now, forcegc, limit; uint64 tick, now, forcegc, limit;
uint32 k; int32 k;
uintptr sumreleased;
Note note, *notep; Note note, *notep;
g->issystem = true; g->issystem = true;
...@@ -476,16 +482,8 @@ runtime·MHeap_Scavenger(void) ...@@ -476,16 +482,8 @@ runtime·MHeap_Scavenger(void)
runtime·lock(h); runtime·lock(h);
now = runtime·nanotime(); now = runtime·nanotime();
} }
sumreleased = scavenge(now, limit); scavenge(k, now, limit);
runtime·unlock(h); runtime·unlock(h);
if(runtime·debug.gctrace > 0) {
if(sumreleased > 0)
runtime·printf("scvg%d: %p MB released\n", k, sumreleased>>20);
runtime·printf("scvg%d: inuse: %D, idle: %D, sys: %D, released: %D, consumed: %D (MB)\n",
k, mstats.heap_inuse>>20, mstats.heap_idle>>20, mstats.heap_sys>>20,
mstats.heap_released>>20, (mstats.heap_sys - mstats.heap_released)>>20);
}
} }
} }
...@@ -494,7 +492,7 @@ runtime∕debug·freeOSMemory(void) ...@@ -494,7 +492,7 @@ runtime∕debug·freeOSMemory(void)
{ {
runtime·gc(1); runtime·gc(1);
runtime·lock(&runtime·mheap); runtime·lock(&runtime·mheap);
scavenge(~(uintptr)0, 0); scavenge(-1, ~(uintptr)0, 0);
runtime·unlock(&runtime·mheap); runtime·unlock(&runtime·mheap);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment