[libcxx-commits] [libcxx] [libc++] Speed up classic locale (PR #72112)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Nov 16 14:49:51 PST 2023
================
@@ -538,16 +549,40 @@ locale::__imp::use_facet(long id) const
// locale
+std::atomic<locale::__imp*> locale::__imp::classic_;
----------------
ldionne wrote:
I think we can do this whole thing differently. First, I suggest a refactor in https://github.com/llvm/llvm-project/pull/72581. Then, I think we can implement this patch as:
```
id locale::__imp::acquire() {
if (this != &locale::classic().__locale_)
__add_shared();
}
```
and correspondingly for `release()`. And we wouldn't need to maintain or store a separate `atomic<__imp*>`. The difference is that with the currently-proposed patch, we pay for one relaxed atomic load when we call `release()` or `acquire()`. With my proposed approach above, we instead pay for a call to `__cxa_acquire` when we enter `locale::classic()`. I'd be curious to see how the two approaches compare performance-wise, but I suspect that any difference might be in the noise.
https://github.com/llvm/llvm-project/pull/72112
More information about the libcxx-commits
mailing list