Discussion:
Does -benchmem include allocations within cgo?
Kamil Kisiel
2014-04-01 07:30:32 UTC
Permalink
I'm benchmarking some pure Go code versus a package that uses cgo and am
wondering how I should interpret the -benchmem results. Are they only
what's allocated at the Go level, or does it also track allocations done
with malloc etc in the C code?
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
Ian Lance Taylor
2014-04-01 13:38:39 UTC
Permalink
Post by Kamil Kisiel
I'm benchmarking some pure Go code versus a package that uses cgo and am
wondering how I should interpret the -benchmem results. Are they only what's
allocated at the Go level, or does it also track allocations done with
malloc etc in the C code?
Only what is allocated at the Go level.

Ian
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
James Bardin
2014-04-01 13:46:33 UTC
Permalink
The go runtime doesn't know anything about what's going on in c-land.
I don't think you can get the same level of granularity out of malloc wile
running under go, since tools like valgrind won't work directly.
I've used both some rough stats collected from mallinfo inside the code, or
switch to tcmalloc and it's profiling options.
Post by Kamil Kisiel
I'm benchmarking some pure Go code versus a package that uses cgo and am
wondering how I should interpret the -benchmem results. Are they only
what's allocated at the Go level, or does it also track allocations done
with malloc etc in the C code?
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
Loading...