[all-commits] [llvm/llvm-project] b019c5: Partially inline basic_string copy constructor...

Martijn Vels via All-commits all-commits at lists.llvm.org
Wed Mar 4 14:54:08 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: b019c5c0372eb08800327efb5e7955ce918b75d1
      https://github.com/llvm/llvm-project/commit/b019c5c0372eb08800327efb5e7955ce918b75d1
  Author: Martijn Vels <mvels at google.com>
  Date:   2020-03-04 (Wed, 04 Mar 2020)

  Changed paths:
    M libcxx/include/__string
    M libcxx/include/string
    A libcxx/test/libcxx/strings/basic.string/string.cons/copy_shrunk_long.pass.cpp

  Log Message:
  -----------
      Partially inline basic_string copy constructor in UNSTABLE

    Summary:
    This is a recommit of https://reviews.llvm.org/D73223 where the added function accidentally ended up inside an idef block.

    This change splits the copy constructor up inlining short initialization, and explicitly outlining long initialization into __init_copy_ctor_external() which is the externally instantiated slow path.

    For unstable ABI, this has the following changes:

    remove basic_string(const basic_string&)
    remove basic_string(const basic_string&, const Allocator&)
    add __init_copy_ctor_external(const value_type*, size_type)
    Quick local benchmark for Copy:

    Master
    ```
    ---------------------------------------------------------------
    Benchmark                    Time             CPU   Iterations
    ---------------------------------------------------------------
    BM_StringCopy_Empty       3.50 ns         3.51 ns    199326720
    BM_StringCopy_Small       3.50 ns         3.51 ns    199510016
    BM_StringCopy_Large       15.7 ns         15.7 ns     45230080
    BM_StringCopy_Huge        1503 ns         1503 ns       464896
    ```
    With this change
    ```
    ---------------------------------------------------------------
    Benchmark                    Time             CPU   Iterations
    ---------------------------------------------------------------
    BM_StringCopy_Empty       1.99 ns         2.00 ns    356471808
    BM_StringCopy_Small       3.29 ns         3.30 ns    203425792
    BM_StringCopy_Large       13.3 ns         13.3 ns     52948992
    BM_StringCopy_Huge        1472 ns         1472 ns       475136
    ```

    Subscribers: libcxx-commits

    Tags: #libc

    Differential Revision: https://reviews.llvm.org/D75639




More information about the All-commits mailing list