Issue |
146141
|
Summary |
[libc++] Look into merging the atomics in __libcpp_contention_table_entry
|
Labels |
libc++
|
Assignees |
huixie90
|
Reporter |
ldionne
|
While discussing with @huixie90 and Apple folks about https://github.com/llvm/llvm-project/issues/109290, it was noticed that `__libcpp_contention_table_entry` defined [here](https://github.com/llvm/llvm-project/blob/52040b44f6060540a0b9d56fdd2e0eb5a540e84c/libcxx/src/atomic.cpp#L121C54-L121C85) contained two atomics when in reality we could merge both into a single atomic:
```
struct alignas(64) /* aim to avoid false sharing */ __libcpp_contention_table_entry {
__cxx_atomic_contention_t __contention_state;
__cxx_atomic_contention_t __platform_state;
inline constexpr __libcpp_contention_table_entry() : __contention_state(0), __platform_state(0) {}
};
```
On Linux, `__cxx_atomic_contention_t` is 32 bits, so we could merge both into a single 64 bits value and perform atomic operations on that directly.
On Apple arm64, `__cxx_atomic_contention_t` is 64 bits, so we could merge both into a single 128 bits value and perform 128-bit atomic operations on that. On Apple x86_64, I don't think we can use this trick (?).
This can potentially simplify the implementation of the contention table algorithm and might be faster.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs