[libcxx-commits] [PATCH] D151274: [libc++] Optimize for_each for segmented iterators

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 23 17:18:34 PDT 2023


philnik added a comment.

Benchmark numbers:

  ---------------------------------------------------
  Benchmark                       old             new
  ---------------------------------------------------
  bm_for_each/1               3.00 ns         2.98 ns
  bm_for_each/2               4.53 ns         4.57 ns
  bm_for_each/3               5.82 ns         5.82 ns
  bm_for_each/4               6.94 ns         6.91 ns
  bm_for_each/5               7.55 ns         7.75 ns
  bm_for_each/6               7.06 ns         7.45 ns
  bm_for_each/7               6.69 ns         7.14 ns
  bm_for_each/8               6.86 ns         4.06 ns
  bm_for_each/16              11.5 ns         5.73 ns
  bm_for_each/64              43.7 ns         4.06 ns
  bm_for_each/512              356 ns         7.98 ns
  bm_for_each/4096            2787 ns         53.6 ns
  bm_for_each/32768          20836 ns          438 ns
  bm_for_each/262144        195362 ns         4945 ns
  bm_for_each/1048576       685482 ns        19822 ns

I think the benchmark numbers aren't in any way surprising (we can get similar numbers with similar patches for most algorithms). This patch is more focused on the actual implementation. This is only optimized for C++20-and-later as-is. The question is whether that is OK for the library. The implementation is a lot easier, but we essentially say "use the latest C++ version or you don't get nice optimizations".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151274



More information about the libcxx-commits mailing list