On Mon, 22 Jun 2020 at 22:49, Andrew Werner <awerne...@gmail.com> wrote:
> > > On Monday, June 22, 2020 at 5:42:12 PM UTC-4, rog wrote: >> >> >> Thanks for pointing this out. I'm cool with this approach. I'll update my >>>> library to utilize it (and consider also adopting the list.List, though I >>>> do like my freedom to pool list nodes). >>>> >>> >> Personally, I'd start by re-using list.List, and only use pools if there >> really is a significant performance benefit to be gained there. >> If you just need zero-valued elements, I could imagine that sync.Pool >> might end up slower than just using the GC. >> > > Fair. > > >> Hopefully with aggressive inlining of the specialized type the compiler >>>> will be able to make the optimizations that it would be able to make if the >>>> slicing were performed directly on an array. >>>> >>> >> What optimisations are you thinking of here? Are you concerned that slice >> operations are too slow? >> > > > * Bound check elimination > I'm not sure how it could do that, given that it's inevitable that an index is stored in a field with no range limits on it (i guess if you used a 256-element array and a uint8 index, it could, but then it wouldn't work for other array sizes). * Avoiding an indirection through the pointer in the slice header would be > nice > Isn't it going to have to indirect through a pointer regardless of whether it's a slice or an array? The array isn't stored inside the Dequeue struct itself. * Compile-time evaluation of len and cap > Isn't that just a one-word load of memory that's very likely in the same cache line as the array-pointer member? I can't see that this is likely to make a significant performance difference, but I'd love to see some numbers. -- 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/CAJhgacjyxP%3Din9L%3Dyz%3D0U2aW_FOufKrzOxFj9sLmdGVohw%2Bdvg%40mail.gmail.com.