[libcxx-commits] [libcxx] [libc++] Optimize `std::exception_ptr` (PR #162773)
Adrian Vogelsgesang via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Oct 20 10:12:12 PDT 2025
vogelsgesang wrote:
> I'm not convinced 2 and 3 are a good idea so far, so I'd rather do them later. I'm happy with (1) though and I think (4) can be implemented separately from moving any code (you seem to have come to the same conclusion below?)
I created
* for "(1) introduce benchmark": #164278
* for "(4) introduce move ctor/assign": #164281
For PR #164281, we already get measurable performance improvements:
```
Benchmark Baseline Candidate Difference % Difference
------------------------------- ---------- ----------- ------------ --------------
bm_nonnull_exception_ptr 52.22 40.92 -11.31 -21.65
bm_null_exception_ptr 31.41 23.29 -8.12 -25.85
bm_optimized_null_exception_ptr 28.69 20.50 -8.19 -28.55
```
With this PR (#162733), we get even better numbers (measured relative to #164281)
```
Benchmark Baseline Candidate Difference % Difference
------------------------------- ---------- ----------- ------------ --------------
bm_nonnull_exception_ptr 40.92 33.69 -7.23 -17.66
bm_null_exception_ptr 23.29 1.21 -22.07 -94.79
bm_optimized_null_exception_ptr 20.50 0.70 -19.80 -96.61
```
I hope that we can ship PR #164278 (introducing the benchmark) pretty much as is.
I am not 100% happy with "(4) introduce move ctor/assign" because I had to
1. the glibcxx implementation of `__do_decrement_refcount` relies on `_M_add_ref`. But this is inconsistent now with other functions, as I did not do "(2) change `src/exception_pointer_glibcxx.ipp` to use `_M_{add,release}ref`" first
2. introduce a new `__do_decrement_refcount` function to the library's ABI. I wasn't able to keep the move assignment completely contained to the header. Doing so would have required me to first do "(3) expose the selected ABI via `__config_site.in`"
https://github.com/llvm/llvm-project/pull/162773
More information about the libcxx-commits
mailing list