Re: [go-nuts] Re: Why are two slices in this example less costly than one?

2017-10-13 Thread Marvin Stenger
I told you the reason already. slice of struct is in the stack frame. Am Freitag, 13. Oktober 2017 16:59:14 UTC+2 schrieb Gabriel Aszalos: > > > For some reason, it seems that allocating a slice of slices takes up quite > a bit of memory, while allocating the slice of structs takes up no memory?

Re: [go-nuts] Re: Why are two slices in this example less costly than one?

2017-10-13 Thread Gabriel Aszalos
Thanks Diego. I didn't know about the `--alloc_space` flag. Quite insightful!!! For anyone else potentially interested in the results, here they are: Here are the results for the original FieldsFunc from the standard library:

Re: [go-nuts] Re: Why are two slices in this example less costly than one?

2017-10-13 Thread Diego Medina
> > > This is exactly what I was trying to figure out how I would be able to do, > and more specifically, if there's an easy way to find out. > > the pprof tool can read a memory or cpu profile created during your benchmark, and then you can see details of your function, line by line, and

Re: [go-nuts] Re: Why are two slices in this example less costly than one?

2017-10-13 Thread Gabriel Aszalos
Superb! Thank you Ian. That is indeed insightful. In my case (as can be seen in the commit message showing the benchstat output), allocations for small ASCII test cases have a delta of +860%, which is 8 times more bytes allocated. You've said: > Then you have to figure out why they are

Re: [go-nuts] Re: Why are two slices in this example less costly than one?

2017-10-10 Thread Ian Lance Taylor
On Tue, Oct 10, 2017 at 12:50 AM, Gabriel Aszalos wrote: > > I would love to find out the answer to this. Even if you don't know the > answer but know how to investigate into it (using pprof or some tracing > flags), I would also appreciate being guided in the right

[go-nuts] Re: Why are two slices in this example less costly than one?

2017-10-10 Thread Gabriel Aszalos
I would love to find out the answer to this. Even if you don't know the answer but know how to investigate into it (using pprof or some tracing flags), I would also appreciate being guided in the right direction and I would love to embark on the journey of finding out myself. What I'm