Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(145)

Issue 12946043: code review 12946043: runtime: account for all sys memory in MemStats (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 9 months ago by dvyukov
Modified:
11 years, 4 months ago
Reviewers:
brainman, rsc
CC:
rsc, dave_cheney.net, brainman, golang-dev
Visibility:
Public.

Description

runtime: account for all sys memory in MemStats Currently lots of sys allocations are not accounted in any of XxxSys, including GC bitmap, spans table, GC roots blocks, GC finalizer blocks, iface table, netpoll descriptors and more. Up to ~20% can unaccounted. This change introduces 2 new stats: GCSys and OtherSys for GC metadata and all other misc allocations, respectively. Also ensures that all XxxSys indeed sum up to Sys. All sys memory allocation functions require the stat for accounting, so that it's impossible to miss something. Also fix updating of mcache_sys/inuse, they were not updated after deallocation. test/bench/garbage/parser before: Sys 670064344 HeapSys 610271232 StackSys 65536 MSpanSys 14204928 MCacheSys 16384 BuckHashSys 1439992 after: Sys 670064344 HeapSys 610271232 StackSys 65536 MSpanSys 14188544 MCacheSys 16384 BuckHashSys 3194304 GCSys 39198688 OtherSys 3129656 Fixes issue 5799.

Patch Set 1 #

Patch Set 2 : diff -r a5954109dae3 https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 3 : diff -r d08cc21a0d0d https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 4 : diff -r aaaa190f025d https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 5 : diff -r aaaa190f025d https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 6 : diff -r 6d4efbff17ed https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 7 : diff -r 6d4efbff17ed https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 8 : diff -r 6d4efbff17ed https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 9 : diff -r 6d4efbff17ed https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 10 : diff -r 6d4efbff17ed https://dvyukov%40google.com@code.google.com/p/go/ #

Total comments: 2

Patch Set 11 : diff -r 5037426bea2f https://dvyukov%40google.com@code.google.com/p/go/ #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+117 lines, -103 lines) Patch
M src/pkg/runtime/cpuprof.c View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M src/pkg/runtime/iface.c View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/runtime/malloc.h View 1 2 3 4 chunks +15 lines, -13 lines 0 comments Download
M src/pkg/runtime/malloc.goc View 1 2 3 4 5 6 6 chunks +12 lines, -9 lines 0 comments Download
M src/pkg/runtime/malloc_test.go View 1 2 3 4 5 6 7 8 9 10 1 chunk +15 lines, -0 lines 1 comment Download
M src/pkg/runtime/mem.go View 1 2 3 4 5 6 2 chunks +3 lines, -1 line 0 comments Download
M src/pkg/runtime/mem_darwin.c View 1 2 3 4 5 6 7 3 chunks +6 lines, -6 lines 0 comments Download
M src/pkg/runtime/mem_freebsd.c View 1 2 3 4 5 6 3 chunks +6 lines, -6 lines 0 comments Download
M src/pkg/runtime/mem_linux.c View 1 2 3 4 5 6 7 4 chunks +6 lines, -6 lines 0 comments Download
M src/pkg/runtime/mem_netbsd.c View 1 2 3 4 5 6 3 chunks +6 lines, -6 lines 0 comments Download
M src/pkg/runtime/mem_openbsd.c View 1 2 3 4 5 6 3 chunks +6 lines, -6 lines 0 comments Download
M src/pkg/runtime/mem_plan9.c View 1 2 3 4 5 6 7 3 chunks +8 lines, -8 lines 0 comments Download
M src/pkg/runtime/mem_windows.c View 1 2 3 4 5 6 3 chunks +6 lines, -6 lines 0 comments Download
M src/pkg/runtime/mfixalloc.c View 1 2 3 3 chunks +3 lines, -4 lines 0 comments Download
M src/pkg/runtime/mgc0.c View 1 2 3 4 5 6 7 8 9 10 5 chunks +10 lines, -6 lines 0 comments Download
M src/pkg/runtime/mheap.c View 1 2 3 4 5 6 7 chunks +5 lines, -14 lines 0 comments Download
M src/pkg/runtime/mprof.goc View 1 2 3 5 chunks +5 lines, -6 lines 0 comments Download
M src/pkg/runtime/netpoll.goc View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/runtime/stack.c View 1 1 chunk +1 line, -2 lines 0 comments Download

Messages

Total messages: 13
dvyukov
Hello rsc (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://dvyukov%40google.com@code.google.com/p/go/
11 years, 9 months ago (2013-08-16 16:24:35 UTC) #1
dave_cheney.net
This should be documented in the 1.2 notes. On 17/08/2013, at 1:24, dvyukov@google.com wrote: > ...
11 years, 9 months ago (2013-08-17 01:34:52 UTC) #2
brainman
https://codereview.appspot.com/12946043/diff/23001/src/pkg/runtime/mem_windows.c File src/pkg/runtime/mem_windows.c (right): https://codereview.appspot.com/12946043/diff/23001/src/pkg/runtime/mem_windows.c#newcode28 src/pkg/runtime/mem_windows.c:28: runtime·xadd64(stat, n); I think you should add these in ...
11 years, 9 months ago (2013-08-17 02:18:37 UTC) #3
dvyukov
https://codereview.appspot.com/12946043/diff/23001/src/pkg/runtime/mem_windows.c File src/pkg/runtime/mem_windows.c (right): https://codereview.appspot.com/12946043/diff/23001/src/pkg/runtime/mem_windows.c#newcode28 src/pkg/runtime/mem_windows.c:28: runtime·xadd64(stat, n); On 2013/08/17 02:18:37, brainman wrote: > I ...
11 years, 9 months ago (2013-08-17 09:34:44 UTC) #4
brainman
On 2013/08/17 09:34:44, dvyukov wrote: > ... > There is HeapReleased for this. Sure is. ...
11 years, 9 months ago (2013-08-19 00:10:56 UTC) #5
brainman
On 2013/08/19 00:10:56, brainman wrote: > > Sure is. Is it possible to add simple ...
11 years, 9 months ago (2013-08-19 00:11:46 UTC) #6
dvyukov
On 2013/08/19 00:10:56, brainman wrote: > On 2013/08/17 09:34:44, dvyukov wrote: > > ... > ...
11 years, 9 months ago (2013-08-19 09:17:09 UTC) #7
dvyukov
On 2013/08/19 09:17:09, dvyukov wrote: > On 2013/08/19 00:10:56, brainman wrote: > > On 2013/08/17 ...
11 years, 9 months ago (2013-08-19 09:17:26 UTC) #8
brainman
Any calculation will do. That is how you discovered the problem, so put a test ...
11 years, 9 months ago (2013-08-19 09:49:20 UTC) #9
dvyukov
On 2013/08/19 09:49:20, brainman wrote: > Any calculation will do. That is how you discovered ...
11 years, 9 months ago (2013-08-19 19:27:59 UTC) #10
brainman
https://codereview.appspot.com/12946043/diff/35001/src/pkg/runtime/malloc_test.go File src/pkg/runtime/malloc_test.go (right): https://codereview.appspot.com/12946043/diff/35001/src/pkg/runtime/malloc_test.go#newcode13 src/pkg/runtime/malloc_test.go:13: func TestMemStats(t *testing.T) { Nice. Thank you.
11 years, 9 months ago (2013-08-20 07:37:21 UTC) #11
rsc
LGTM
11 years, 8 months ago (2013-09-06 19:45:16 UTC) #12
rsc
11 years, 8 months ago (2013-09-06 20:55:43 UTC) #13
*** Submitted as https://code.google.com/p/go/source/detail?r=cbacca9a8c67 ***

runtime: account for all sys memory in MemStats
Currently lots of sys allocations are not accounted in any of XxxSys,
including GC bitmap, spans table, GC roots blocks, GC finalizer blocks,
iface table, netpoll descriptors and more. Up to ~20% can unaccounted.
This change introduces 2 new stats: GCSys and OtherSys for GC metadata
and all other misc allocations, respectively.
Also ensures that all XxxSys indeed sum up to Sys. All sys memory allocation
functions require the stat for accounting, so that it's impossible to miss
something.
Also fix updating of mcache_sys/inuse, they were not updated after deallocation.

test/bench/garbage/parser before:
Sys		670064344
HeapSys		610271232
StackSys	65536
MSpanSys	14204928
MCacheSys	16384
BuckHashSys	1439992

after:
Sys		670064344
HeapSys		610271232
StackSys	65536
MSpanSys	14188544
MCacheSys	16384
BuckHashSys	3194304
GCSys		39198688
OtherSys	3129656

Fixes issue 5799.

R=rsc, dave, alex.brainman
CC=golang-dev
https://codereview.appspot.com/12946043

Committer: Russ Cox <rsc@golang.org>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b