Jinoh Kang (@iamahuman) commented about dlls/ntdll/heap.c:
+/* affinity to tid mapping array, limits the number of thread-local caches,
- and additional threads will fight for the global categories groups
- */
+static LONG next_thread_affinity;
+/* a category of heap blocks of a certain size */ +struct category +{
- /* counters for LFH activation */
- volatile LONG blocks_alive;
- volatile LONG blocks_total;
- volatile BOOL enabled;
- /* list of groups with free blocks */
- SLIST_HEADER groups;
- struct group *affinity_group[32];
This array is intended to be accessed atomically by multiple threads, but a substantial number of elements reside in a cache line (assuming 64 byte cache line size). This results in false sharing, which may impact performance compared to purely threaded heaps.