[libcxx-commits] [PATCH] D101752: Speedup to_string for integers using zero-copy.
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sat May 8 08:25:46 PDT 2021
Quuxplusone requested changes to this revision.
Quuxplusone added a comment.
This revision now requires changes to proceed.
@Roman-Koshelev: By "benchmark," I think we mean putting it in the diff proper. Here's the patch I was about to suggest... https://pastebin.com/raw/Jg2htyVG ...except that then I //ran// that benchmark (with and without the patch to src/) and was unable to detect any performance improvement. Changing the first `resize` to `__resize_default_init` helped, but not enough.
$ bin/clang++ -O2 ../libcxx/benchmarks/to_string.bench.cpp lib/libc++.a lib/libc++abi.a -I ../libcxx/utils/google-benchmark/include/ -L /usr/local/lib -lbenchmark -o new.exe
$ ./new.exe
2021-05-08T11:16:51-04:00
Running ./new.exe
Run on (8 X 2200 MHz CPU s)
CPU Caches:
L1 Data 32 KiB (x4)
L1 Instruction 32 KiB (x4)
L2 Unified 256 KiB (x4)
L3 Unified 6144 KiB (x1)
Load Average: 1.72, 2.07, 2.17
----------------------------------------------------------
Benchmark Time CPU Iterations
----------------------------------------------------------
BM_ToString/1 9156 ns 9152 ns 74252
BM_ToString/2 9207 ns 9203 ns 74929
BM_ToString/3 10199 ns 10192 ns 67968
BM_ToString/4 10034 ns 10027 ns 68924
BM_ToString/5 11141 ns 11118 ns 63743
BM_ToString/6 11534 ns 11485 ns 62568
BM_ToString/7 11926 ns 11925 ns 58581
BM_ToString/8 12282 ns 12257 ns 52108
BM_ToString/9 13072 ns 13033 ns 51947
BM_ToString/10 13010 ns 12994 ns 53775
BM_ToWstring/1 6809 ns 6808 ns 101851
BM_ToWstring/2 7863 ns 7849 ns 88482
BM_ToWstring/3 8748 ns 8735 ns 77942
BM_ToWstring/4 9448 ns 9409 ns 77254
BM_ToWstring/5 88436 ns 88398 ns 7768
BM_ToWstring/6 88524 ns 88499 ns 7703
BM_ToWstring/7 90242 ns 90205 ns 7622
BM_ToWstring/8 92892 ns 92575 ns 7279
BM_ToWstring/9 90693 ns 90591 ns 7435
BM_ToWstring/10 93344 ns 93128 ns 7646
$ git checkout main -- ../libcxx/src/string.cpp
$ ninja cxx ; ninja cxx ; ninja cxx
[5/5] Creating library symlink lib/libc++.1.dylib lib/libc++.dylib
[1/1] Linking CXX static library lib/libc++.a
ninja: no work to do.
$ bin/clang++ -O2 ../libcxx/benchmarks/to_string.bench.cpp lib/libc++.a lib/libc++abi.a -I ../libcxx/utils/google-benchmark/include/ -L /usr/local/lib -lbenchmark -o old.exe
$ ./old.exe
2021-05-08T11:18:56-04:00
Running ./old.exe
Run on (8 X 2200 MHz CPU s)
CPU Caches:
L1 Data 32 KiB (x4)
L1 Instruction 32 KiB (x4)
L2 Unified 256 KiB (x4)
L3 Unified 6144 KiB (x1)
Load Average: 2.54, 2.45, 2.31
----------------------------------------------------------
Benchmark Time CPU Iterations
----------------------------------------------------------
BM_ToString/1 8390 ns 8386 ns 79859
BM_ToString/2 9494 ns 9488 ns 72932
BM_ToString/3 10157 ns 10152 ns 67160
BM_ToString/4 10708 ns 10691 ns 66018
BM_ToString/5 12084 ns 12068 ns 57079
BM_ToString/6 12080 ns 12074 ns 56325
BM_ToString/7 13303 ns 13295 ns 51666
BM_ToString/8 12070 ns 12062 ns 56550
BM_ToString/9 12610 ns 12605 ns 55151
BM_ToString/10 12362 ns 12357 ns 55914
BM_ToWstring/1 6791 ns 6787 ns 101672
BM_ToWstring/2 7698 ns 7696 ns 89471
BM_ToWstring/3 8682 ns 8672 ns 79495
BM_ToWstring/4 9499 ns 9466 ns 76316
BM_ToWstring/5 93702 ns 93611 ns 7603
BM_ToWstring/6 95741 ns 95541 ns 7602
BM_ToWstring/7 98949 ns 98798 ns 6976
BM_ToWstring/8 94875 ns 94835 ns 7649
BM_ToWstring/9 94720 ns 94675 ns 7441
BM_ToWstring/10 94846 ns 94802 ns 7011
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101752/new/
https://reviews.llvm.org/D101752
More information about the libcxx-commits
mailing list