puzpuzpuz/xsync

Range Causes extra memory allocations

zetoqu opened this issue · 1 comments

Hi,
Your project and hard-work is very much appreciated.
My use case needs the map to be ranged as fast as possible ( Maybe million of times every second and this behavior will continue for entire service duration) . However, the following line

xsync/mapof.go

Line 319 in f620963

bentries := make([]rangeEntry, 0, entriesPerMapBucket)

cause memory allocation always. ( causing unnecessary garbage and thus GC cycles )
This memory allocation can go away if a fixed array is used instead.

Thank you.

Thanks for pointing this out. #45 gets rid of allocations and also removes locking which leads to better performance in uncontended cases.