[libcxx-commits] [PATCH] D67524: P1144 "Trivially relocatable" (3/3): optimize std::vector and std::swap for trivially relocatable types

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 18 20:55:04 PDT 2019


Quuxplusone updated this revision to Diff 220798.
Quuxplusone added a comment.

Add a new benchmark, and add a `TriviallyRelocatableType` to the matrix in `algorithms.bench.cpp`.

My expectation is that `swap.bench.cpp` should get noticeably faster after this patch.

My less confident expectation is that the new `.*trivre.*` test cases in `algorithms.bench.cpp` should initially be noticeably worse than the `.*string.*` cases, but after this patch they should catch up. What's happening there is that when you swap strings, you're calling string's own ADL overload of `swap` which is very fast, but when you swap `TriviallyRelocatableType`s, you're calling the generic `std::swap<TriviallyRelocatableType>` which is not quite so fast until this patch makes it do memcpy.

I'm putting the benchmarks right here in this patch so that @ericwf can run them. (Zoe and I produced some good-looking benchmark numbers earlier tonight, with code similar to this code; but my build tree is too screwed up to reproduce them on demand.)


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67524/new/

https://reviews.llvm.org/D67524

Files:
  benchmarks/algorithms.bench.cpp
  benchmarks/swap.bench.cpp
  include/memory
  include/type_traits
  include/vector

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67524.220798.patch
Type: text/x-patch
Size: 17700 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190919/6362b46b/attachment-0001.bin>


More information about the libcxx-commits mailing list