[libcxx-commits] [PATCH] D131395: [libc++] Implement `lexicographical_compare_three_way`

Konstantin Varlamov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Dec 8 22:02:22 PST 2022


var-const added a comment.

@avogelsgesang  Update: from our conversation offline, it sounds like you were compiling in the `RelWithDebugInfo` mode. I tried running in this mode and got almost the same results as I'm getting from the `Debug` mode:

  -----------------------------------------------------------------------------------------------------------------------
  Benchmark                                                                             Time             CPU   Iterations
  -----------------------------------------------------------------------------------------------------------------------
  BM_lexicographical_compare_three_way<IntPtr>/1                                     25.3 ns         25.3 ns     27412710
  BM_lexicographical_compare_three_way<IntPtr>/4                                     62.5 ns         62.5 ns     11168728
  BM_lexicographical_compare_three_way<IntPtr>/16                                     229 ns          229 ns      3061662
  BM_lexicographical_compare_three_way<IntPtr>/64                                     832 ns          832 ns       836110
  BM_lexicographical_compare_three_way<IntPtr>/256                                   3259 ns         3244 ns       216064
  BM_lexicographical_compare_three_way<IntPtr>/1024                                 12861 ns        12861 ns        53949
  BM_lexicographical_compare_three_way<IntPtr>/4096                                 51802 ns        51716 ns        13595
  BM_lexicographical_compare_three_way<IntPtr>/16384                               206718 ns       206713 ns         3392
  BM_lexicographical_compare_three_way<IntPtr>/65536                               830742 ns       830742 ns          841
  BM_lexicographical_compare_three_way<IntPtr>/262144                             3319157 ns      3319157 ns          210
  BM_lexicographical_compare_three_way<IntPtr>/1048576                           13304895 ns     13304887 ns           53
  BM_lexicographical_compare_three_way<random_access_iterator<IntPtr>>/1             36.7 ns         36.7 ns     19072166
  BM_lexicographical_compare_three_way<random_access_iterator<IntPtr>>/4             83.8 ns         83.8 ns      8343664
  BM_lexicographical_compare_three_way<random_access_iterator<IntPtr>>/16             278 ns          278 ns      2517795
  BM_lexicographical_compare_three_way<random_access_iterator<IntPtr>>/64            1011 ns         1011 ns       690833
  BM_lexicographical_compare_three_way<random_access_iterator<IntPtr>>/256           3942 ns         3942 ns       177553
  BM_lexicographical_compare_three_way<random_access_iterator<IntPtr>>/1024         15883 ns        15883 ns        44076
  BM_lexicographical_compare_three_way<random_access_iterator<IntPtr>>/4096         62650 ns        62650 ns        11167
  BM_lexicographical_compare_three_way<random_access_iterator<IntPtr>>/16384       251600 ns       251600 ns         2785
  BM_lexicographical_compare_three_way<random_access_iterator<IntPtr>>/65536      1011288 ns      1011281 ns          691
  BM_lexicographical_compare_three_way<random_access_iterator<IntPtr>>/262144     4049729 ns      4049734 ns          173
  BM_lexicographical_compare_three_way<random_access_iterator<IntPtr>>/1048576   16211147 ns     16210558 ns           43
  BM_lexicographical_compare_three_way<cpp17_input_iterator<IntPtr>>/1               29.0 ns         29.0 ns     24190232
  BM_lexicographical_compare_three_way<cpp17_input_iterator<IntPtr>>/4               96.5 ns         96.5 ns      7311392
  BM_lexicographical_compare_three_way<cpp17_input_iterator<IntPtr>>/16               294 ns          294 ns      2384261
  BM_lexicographical_compare_three_way<cpp17_input_iterator<IntPtr>>/64              1087 ns         1087 ns       639433
  BM_lexicographical_compare_three_way<cpp17_input_iterator<IntPtr>>/256             4262 ns         4262 ns       164443
  BM_lexicographical_compare_three_way<cpp17_input_iterator<IntPtr>>/1024           17241 ns        17241 ns        40814
  BM_lexicographical_compare_three_way<cpp17_input_iterator<IntPtr>>/4096           67701 ns        67701 ns        10315
  BM_lexicographical_compare_three_way<cpp17_input_iterator<IntPtr>>/16384         274331 ns       274317 ns         2584
  BM_lexicographical_compare_three_way<cpp17_input_iterator<IntPtr>>/65536        1090526 ns      1090491 ns          623
  BM_lexicographical_compare_three_way<cpp17_input_iterator<IntPtr>>/262144       4360529 ns      4360525 ns          160
  BM_lexicographical_compare_three_way<cpp17_input_iterator<IntPtr>>/1048576     17474668 ns     17474650 ns           40

I'm surprised by these results (I also expected `RelWithDebugInfo` to produce an optimized build). However, it does explain the timings we were seeing. You might want to try `Debug` and `Release` modes locally to confirm (completely optional), but the important thing is that there is no issue in the patch. I'll dig into the unexpected behavior of `RelWithDebugInfo` later.

Thanks for pointing out you were using `RelWithDebugInfo`, btw! My original guess re. `Debug` was incorrect.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131395



More information about the libcxx-commits mailing list