-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Labels
Description
File: Utilities/AtomicLongArray.cs
The LazySet implementation (used in ClearCounts) does a plain write then calls Interlocked.MemoryBarrier() — which emits a full fence, defeating the purpose of a lazy/relaxed write. The comment in the code even acknowledges uncertainty about this. On modern x86 this is largely harmless due to TSO, but on ARM64 (e.g. AWS Graviton, Apple Silicon) a full fence is expensive and wrong for this use case. The correct modern equivalent is:
Volatile.Write(ref _counts[index], value);
Volatile.Write emits a store-release fence (half-fence) rather than a full fence, which is precisely what Java's lazySet maps to on ARM64.
Reactions are currently unavailable