[libcxx-commits] [libcxxabi] [libcxx] [libcxxabi] Dont throw in make exception ptr if __cxa_init_primary_exception is available (PR #65534)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Oct 15 11:09:12 PDT 2023
itrofimow wrote:
Benchmarks to back the performance claims up:
```
itrofimow at itrofimow-nix:~/work/llvm-project/ex_ptr_bench$ taskset -c 8-15 ~/work/gbench/tools/compare.py benchmarks ./main_libcxxabi ./patch_libcxxabi
RUNNING: ./main_libcxxabi --benchmark_out=/tmp/tmpi96tlrpa
2023-10-15T20:57:14+03:00
Running ./main_libcxxabi
Run on (16 X 1280.96 MHz CPU s)
CPU Caches:
L1 Data 48 KiB (x8)
L1 Instruction 32 KiB (x8)
L2 Unified 1280 KiB (x8)
L3 Unified 24576 KiB (x1)
Load Average: 0.36, 1.30, 1.61
--------------------------------------------------------------------------
Benchmark Time CPU Iterations
--------------------------------------------------------------------------
bm_make_exception_ptr/threads:1 745 ns 745 ns 950011
bm_make_exception_ptr/threads:2 816 ns 1633 ns 455610
bm_make_exception_ptr/threads:4 863 ns 3208 ns 227044
bm_make_exception_ptr/threads:8 1120 ns 8064 ns 87896
RUNNING: ./patch_libcxxabi --benchmark_out=/tmp/tmpvd2nklsl
2023-10-15T20:57:16+03:00
Running ./patch_libcxxabi
Run on (16 X 1259.78 MHz CPU s)
CPU Caches:
L1 Data 48 KiB (x8)
L1 Instruction 32 KiB (x8)
L2 Unified 1280 KiB (x8)
L3 Unified 24576 KiB (x1)
Load Average: 0.36, 1.30, 1.61
--------------------------------------------------------------------------
Benchmark Time CPU Iterations
--------------------------------------------------------------------------
bm_make_exception_ptr/threads:1 25.6 ns 25.6 ns 27321613
bm_make_exception_ptr/threads:2 12.7 ns 25.4 ns 27881074
bm_make_exception_ptr/threads:4 6.84 ns 27.4 ns 27500684
bm_make_exception_ptr/threads:8 3.56 ns 28.5 ns 25787520
Comparing ./main_libcxxabi to ./patch_libcxxabi
Benchmark Time CPU Time Old Time New CPU Old CPU New
------------------------------------------------------------------------------------------------------------------------------
bm_make_exception_ptr/threads:1 -0.9656 -0.9656 745 26 745 26
bm_make_exception_ptr/threads:2 -0.9844 -0.9844 816 13 1633 25
bm_make_exception_ptr/threads:4 -0.9921 -0.9915 863 7 3208 27
bm_make_exception_ptr/threads:8 -0.9968 -0.9965 1120 4 8064 28
OVERALL_GEOMEAN -0.9892 -0.9887 0 0 0 0
```
It can be seen that with the patch not only the performance is x30(!) in single-threaded case, but it also scales linearly with the number of threads (CPU / Time == number of threads), when on current thunk it's not the case: i'm using not the most recent gcc's unwinder, so contention on the lock in `dl_iterate_phdr` takes place.
The effect is the same with `libcxxrt`, although it seems to be a bit slower overall.
I've addressed review comments and the build is green. so re-requesting the review.
https://github.com/llvm/llvm-project/pull/65534
More information about the libcxx-commits
mailing list