On Sun, Aug 4, 2019 at 6:06 PM Robert Engels <reng...@ix.netcom.com> wrote: > > Just because you declare in functions and pass around does not have anything > to do if it will be on the heap or the stack. It depends on if the compiler > can detect if the object does not “escape”.
Right. However, if the variables are declared globally (as I understand it is the first case in the post), then there is no chance that they will be on stack. > > > On Aug 4, 2019, at 5:35 PM, burak serdar <bser...@computer.org> wrote: > > > >> On Sun, Aug 4, 2019 at 11:19 AM B Carr <buc...@gmail.com> wrote: > >> > >> Concept observation. Could use some amplification from the congregants, > >> please... > >> > >> I'm learning about Go. > >> > >> My webserver program had lots of package level vars and only two, small > >> structs. I set a dozen webpages to refresh very busy data calculations > >> every 6 seconds. Over the course of an hour, looking at the pprof output > >> for 'alloc' & 'heapAlloc' it looked like the GC was very busy and > >> collected >6 GiB of stuff. It looked like it would have continued > >> increasing into infinity. Even during that time, the GC rarely went over > >> 10ms active times. > >> > >> I got rid of all the package level vars and put them inside of structs and > >> pass around the struct values to the functions as needed. Using the same > >> test setup above, I set a dozen webpages to refresh very busy data > >> calculations every 6 seconds. Over the course of an hour, looking at the > >> pprof output for 'alloc' & 'heapAlloc' it looked like the GC just loafed > >> along and collected <10 MiB of stuff. And that number was pretty level. > >> The GC was showing mostly zero nanosecond times. > > > > The GC activity will depend on what goes to the heap. I can't say I > > understand your program structure from your description, but it sounds > > like in the first case you have global variables, but in the second > > case you started declaring variables in your functions and passed them > > around. If that's really the case, then GC will have less to do in the > > second case as most of the memory will be allocated on the stack, and > > GC will not be involved in cleaning them up. > > > >> > >> I didn't do any timing testing, but the speediness of all the webpages > >> felt about the same in both test cases. > >> > >> I have a notion about what I'm seeing. Anyone care to increase my level of > >> understanding? Are my interpretations about what pprof is showing me > >> accurate? > >> > >> (ps - a big thank you to Burak Serdar who, in a previous thread, showed me > >> something I hadn't considered and put me on the path to making my > >> webserver program successfully concurrent!) > >> > >> TIA, > >> > >> Bucky > >> > >> -- > >> 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+unsubscr...@googlegroups.com. > >> To view this discussion on the web visit > >> https://groups.google.com/d/msgid/golang-nuts/fb49d5bb-f795-4ca3-af5c-d883aabcf1af%40googlegroups.com. > > > > -- > > 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+unsubscr...@googlegroups.com. > > To view this discussion on the web visit > > https://groups.google.com/d/msgid/golang-nuts/CAMV2RqrEB7nOOx-CytFXYiTu7s5PosPZP%3D1ugJsE6MxK6KtwJA%40mail.gmail.com. > > -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/F94EF844-937B-47AF-BC45-DACCCB267107%40ix.netcom.com. -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAMV2Rqr1nU9FGSgm1h-qcHW74Pk2ms42uvgMR%3D%2Bw6HjJgRT7DA%40mail.gmail.com.