On Thu, May 03, 2012 at 08:39:51AM +0200, R�ソスmy Oudompheng wrote:
> 2012/5/3 Matt Davis <
mattd...@gmail.com>:
> > On Thu, May 3, 2012 at 4:22 PM, Ian Lance Taylor <
ia...@google.com> wrote:
> >> Matt Davis <
mattd...@gmail.com> writes:
> >>
> >>> I am gathering various memory usage statistics from a particular Go
> >>> benchmark. �ソスAt the end of the gccgo-4.6.3 compiled program, which is
> >>> deterministic, I will occasionally find different NumGC TotalAlloc and
> >>> Mallocs values from the 'MemStats' object. �ソスI am only running single
> >>> threaded code, therefore not explicitly spawning any go threads. �ソスAny
> >>> idea why the NumGC and various other data are not always the same
> >>> given the same input?
> >>
> >> In gccgo 4.6 different goroutines run on different threads, and the
> >> order in which they execute is unpredictable. �ソスYou say that you don't
> >> spawn any Go threads, by which I assume you mean that you don't use the
> >> go statement, but many of the standard packages do use the go statement.
> >> Perhaps that is what is happening here.
> >
> > Thanks for the reply!
> > That is quite possible. �ソスHowever, the difference between runs can be
> > as significant as having NumGC report: �ソス144932 or 80973. �ソスThat's a
> > pretty big difference. �ソスIt is almost consistently 144932, but rarely I
> > will see a value like 80973. �ソスSo, for my next area of investigation, I
> > decided to use gdb and set a break point on pthread_create; nothing
> > tripped. �ソスI also paused the program in gdb and did a 'info threads'
> > and still, just a single thread.
>
> What does the benchmark look like?
I was testing performance using this application:
https://github.com/dchest/passwordhash
I purposely removed any 'go' statements, but there are none in this case aside
from, as Ian pointed out, those which might be in the libraries called (e.g. the
crypto libraries). I tossed in a:
>> println("NumGC: ", runtime.MemStats.NumGC)
at the end of the main() block, as well as a few other MemStat fields. I loop
over the provided test numerous times in a single "run." I am wondering if the
occasional difference in NumGC values has something to do with multiple CPUs
(quad-core i7) and possibly the stress of running the test is causing the CPU to
offload work to other processors, and caches.
-Matt