-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
There are some optimizations not available with managed code in .Net because there are currently no ways to enforce a memory alignment greater than the pointer size:
- Interlocked 64bit in x86 process when the underlying OS is 64bit (See discussion in issue ThreadPool's UnfairSemaphore Interlocked64 operation on misaligned address in x86 #4811)
- Interlocked 128bit
- Cache line alignment optimizations
I have no idea if this is easy or hard in the current coreclr design, but it would be nice to have a MemoryAlignmentAttribute
that could specify alignment minimally on class type and possibly on any class/struct/field.
My motivation for this feature would be to implement an UnfairSemaphore (#2383) that isn't randomly inefficient in x86 when its 64bit state crosses a cache line boundary.
I have created a gist to isolate the consequences of unaligned Interlocked:
https://gist.github.com/JeffCyr/9e162f440e30b567507cc95b6ba5a4a4
On my machine, unaligned Interlocked operation can be 61x slower.
category:proposal
theme:alignment
skill-level:expert
cost:large
impact:medium
Metadata
Metadata
Assignees
Labels
Type
Projects
Status