News for hackers. Stuff that matters.
Re:Writing memory efficient C structs by zeusk on Wednesday July 30, 2025 @06:42PM (#44740399)
The real issue with packed structs and bitfields happens when concurrency gets involved. Majority of modern CPU caches are private and only allow one core to hold the cache line - so it creates more false dependencies when cores are trying to alter information that was compacted into a cache line on another core.
Re:Writing memory efficient C structs by charleslmunger on Wednesday July 30, 2025 @10:50PM (#44741897)
Avoiding false sharing is a separate problem best solved by explicitly aligning the struct or relevant members to std::hardware_destructive_interference_size.