Heap fragmentation due to protobuffs serialization/de-serialization

291 views
Skip to first unread message

Devanand Reddy

unread,
Nov 28, 2016, 11:12:36 AM11/28/16
to golang-nuts
Hi there,

We are using protocol buffers extensively in our application. We have a suspect that over the time, due to excessive  marshaling/un-marshaling these two operations are causing heap fragmentation. One factor I am looking at, to come to this conclusion is HeapIdle. In my tests, though HeapInUse is coming back to my expectation, HeapIdle is staying there forever. On another note, our protobuff operations consume any where between 700-900mb, given the size of the data we are trying to serialize. 
I am attaching a few graphs here.

Please advise whether this is a sign for concern.

Thanks.
approx 1GB data - no old snapshot .png
approx 800mb data.png

Ian Lance Taylor

unread,
Nov 28, 2016, 1:06:47 PM11/28/16
to Devanand Reddy, golang-nuts
Heap fragmentation is not normally a concern with the current Go
runtime. The heap is implemented to that large pages are divided up
into blocks that are all the same size. This means that the usual
definition of fragmentation--a small block prevents coalescing of
large blocks--can not occur.

Your graphs seem to show your memory use is in a steady state, which
is a good thing. When there are operations that temporarily use a lot
of memory, it's normal for HeapIdle to be high--the memory is there
ready and waiting for temporary memory use spikes.

Ian

Dave Cheney

unread,
Nov 28, 2016, 3:48:40 PM11/28/16
to golang-nuts
It looks ok to me, the svg.released number is growing which suggests that fragmentation is not an issue.
Reply all
Reply to author
Forward
0 new messages