On Sunday, 16 May 2021 at 08:07:17 UTC+1 tapi...@gmail.com wrote: > > you don't provide memory allocation statistics, > > There are no surprises in memory allocation statistics so I didn't mention > them. > > I think it is relevant, because your different functions return slices of different capacity (i.e. different amounts of memory allocated): https://play.golang.org/p/3IQzd6J1ADa
The only functions which allocate exactly the right size of slice are InsertVerbose and InsertVerbose_b. The others rely on append(), and when that exceeds the size of the current slice and has to allocate a new one, it allocates a bit extra space for growing room. Therefore, you could be measuring boundary conditions around the size that append() decides to round your slice up to, combined with amount of garbage collection overhead for large values of N. Aside: larger values like N = 1615119 end up with SIGKILL in the playground - presumably using too much memory - but run locally: ======== N = 1615119 InsertOneline: cap=2524160 InsertOneline_Disassemble: cap=2524160 InsertVerbose: cap=2422678 InsertVerbose_b: cap=2422678 InsertVerbose_c: cap=2422784 -- 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/7ff078be-b3ea-4984-b098-f61498284609n%40googlegroups.com.