[libcxx-commits] [PATCH] D139554: [libc++] Forward to std::memcmp for trivially comparable types in equal

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Dec 10 15:23:39 PST 2022


philnik created this revision.
Herald added a project: All.
philnik updated this revision to Diff 481166.
philnik added a comment.
philnik updated this revision to Diff 481274.
philnik updated this revision to Diff 481463.
philnik retitled this revision from "[libc++] Forward to std::memcmp for trivially comparable types" to "[libc++] Forward to std::memcmp for trivially comparable types in equal".
philnik updated this revision to Diff 481490.
philnik updated this revision to Diff 481597.
philnik updated this revision to Diff 481845.
philnik updated this revision to Diff 481863.
philnik updated this revision to Diff 481867.
philnik published this revision for review.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Add a benchmark and tests


philnik added a comment.

Generate files


philnik added a comment.

Fix some stuff


philnik added a comment.

Try to fix CI


philnik added a comment.

Try to fix CI


philnik added a comment.

Next try


philnik added a comment.

Next try


philnik added a comment.

Fix C++03


philnik added a comment.

  --------------------------------------------------------
  Benchmark                              old           new
  --------------------------------------------------------
  bm_equal_iter/1                   0.926 ns       2.08 ns
  bm_equal_iter/2                    1.36 ns       2.20 ns
  bm_equal_iter/3                    1.78 ns       2.10 ns
  bm_equal_iter/4                    2.26 ns       2.10 ns
  bm_equal_iter/5                    2.72 ns       2.09 ns
  bm_equal_iter/6                    3.20 ns       2.10 ns
  bm_equal_iter/7                    3.63 ns       2.10 ns
  bm_equal_iter/8                    4.11 ns       2.10 ns
  bm_equal_iter/16                   7.84 ns       2.10 ns
  bm_equal_iter/64                   30.6 ns       1.89 ns
  bm_equal_iter/512                   241 ns       6.41 ns
  bm_equal_iter/4096                 1895 ns       40.9 ns
  bm_equal_iter/32768               15152 ns        485 ns
  bm_equal_iter/262144             120923 ns       4331 ns
  bm_equal_iter/1048576            484883 ns      20014 ns
  bm_equal/1                         1.16 ns       2.31 ns
  bm_equal/2                         1.51 ns       2.32 ns
  bm_equal/3                         1.85 ns       2.32 ns
  bm_equal/4                         2.31 ns       2.32 ns
  bm_equal/5                         2.87 ns       2.32 ns
  bm_equal/6                         3.27 ns       2.32 ns
  bm_equal/7                         3.75 ns       2.32 ns
  bm_equal/8                         4.19 ns       2.32 ns
  bm_equal/16                        7.88 ns       2.32 ns
  bm_equal/64                        30.4 ns       2.09 ns
  bm_equal/512                        241 ns       6.54 ns
  bm_equal/4096                      1892 ns       41.1 ns
  bm_equal/32768                    15078 ns        483 ns
  bm_equal/262144                  120725 ns       4318 ns
  bm_equal/1048576                 482791 ns      19228 ns
  bm_ranges_equal/1                  1.16 ns       2.08 ns
  bm_ranges_equal/2                  1.50 ns       2.09 ns
  bm_ranges_equal/3                  1.85 ns       2.09 ns
  bm_ranges_equal/4                  2.20 ns       2.09 ns
  bm_ranges_equal/5                  2.54 ns       2.09 ns
  bm_ranges_equal/6                  2.89 ns       2.09 ns
  bm_ranges_equal/7                  3.24 ns       2.10 ns
  bm_ranges_equal/8                  3.58 ns       2.09 ns
  bm_ranges_equal/16                 6.36 ns       2.10 ns
  bm_ranges_equal/64                 28.5 ns       1.87 ns
  bm_ranges_equal/512                 183 ns       6.41 ns
  bm_ranges_equal/4096               1428 ns       41.3 ns
  bm_ranges_equal/32768             11390 ns        483 ns
  bm_ranges_equal/262144            91268 ns       4187 ns
  bm_ranges_equal/1048576          363866 ns      20177 ns

Note that this decreases binary size at the same time, since this forwards to a C library function now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139554

Files:
  libcxx/benchmarks/CMakeLists.txt
  libcxx/benchmarks/algorithms/equal.bench.cpp
  libcxx/include/CMakeLists.txt
  libcxx/include/__algorithm/comp.h
  libcxx/include/__algorithm/equal.h
  libcxx/include/__algorithm/make_projected.h
  libcxx/include/__algorithm/ranges_equal.h
  libcxx/include/__algorithm/unwrap_iter.h
  libcxx/include/__algorithm/unwrap_range.h
  libcxx/include/__functional/identity.h
  libcxx/include/__functional/operations.h
  libcxx/include/__functional/ranges_operations.h
  libcxx/include/__type_traits/is_comparable.h
  libcxx/include/__type_traits/is_predicate_kind.h
  libcxx/include/module.modulemap.in
  libcxx/test/libcxx/private_headers.verify.cpp
  libcxx/test/libcxx/transitive_includes/cxx03.csv
  libcxx/test/libcxx/transitive_includes/cxx11.csv
  libcxx/test/libcxx/transitive_includes/cxx14.csv
  libcxx/test/libcxx/transitive_includes/cxx17.csv
  libcxx/test/libcxx/transitive_includes/cxx20.csv
  libcxx/test/libcxx/transitive_includes/cxx2b.csv
  libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp
  libcxx/test/std/algorithms/robust_against_adl.compile.pass.cpp
  libcxx/test/support/test_iterators.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139554.481867.patch
Type: text/x-patch
Size: 35909 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221210/e2e9a285/attachment-0001.bin>


More information about the libcxx-commits mailing list