2 ms·
Same object doesn't have to be contended if the reference count is sharing cache line with another reference count. I've seen this happen in cases arrays of ob
by magicalhippo 2y ago
Same object doesn't have to be contended if the reference count is sharing cache line with another reference count.
I've seen this happen in cases arrays of objects are allocated, ie one per thread, and then handed to a thread pool to work on.
Even if heap allocated, if the object is just a reference counter and a few pointers, the memory allocator can fit several of them next to each other causing them to share cache lines, which causes the performance issues with atomic operations.
Depends on implementation of things of course, but can be a pitfall.