[libcxx-commits] [PATCH] D75211: Partially inline basic_string::operator=(const basic_string&)
Martijn Vels via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Feb 26 13:06:42 PST 2020
mvels created this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
mvels added reviewers: EricWF, ldionne.
Herald added a subscriber: dexonsmith.
Herald added a reviewer: mclow.lists.
mvels updated this revision to Diff 246823.
mvels added a comment.
Fix left behind comment
This change partially inlines operator=(const basic_string&) where both the input and current instance are short strings, making the assignment a fixed length inlined memcpy.
Assignments where either of the strings are long are delegate to __assign_no_alias<__is_short>(), which is templated for the long / short branch already observed in the caller.
Stable:
--------------------------------------------------------------------------------
Benchmark Time CPU Iterations
--------------------------------------------------------------------------------
BM_StringAssignStr_Empty_Opaque 2.65 ns 2.66 ns 263745536
BM_StringAssignStr_Empty_Transparent 2.95 ns 2.96 ns 236494848
BM_StringAssignStr_Small_Opaque 2.93 ns 2.94 ns 237301760
BM_StringAssignStr_Small_Transparent 2.69 ns 2.69 ns 265809920
BM_StringAssignStr_Large_Opaque 19.6 ns 19.6 ns 35573760
BM_StringAssignStr_Large_Transparent 19.1 ns 19.1 ns 36716544
BM_StringAssignStr_Huge_Opaque 1901 ns 1901 ns 364544
BM_StringAssignStr_Huge_Transparent 1889 ns 1889 ns 360448
Unstable
--------------------------------------------------------------------------------
Benchmark Time CPU Iterations
--------------------------------------------------------------------------------
BM_StringAssignStr_Empty_Opaque 1.29 ns 1.29 ns 540454912
BM_StringAssignStr_Empty_Transparent 1.11 ns 1.12 ns 628482048
BM_StringAssignStr_Small_Opaque 1.29 ns 1.29 ns 541216768
BM_StringAssignStr_Small_Transparent 1.11 ns 1.11 ns 629469184
BM_StringAssignStr_Large_Opaque 15.6 ns 15.6 ns 44945408
BM_StringAssignStr_Large_Transparent 14.9 ns 14.9 ns 46764032
BM_StringAssignStr_Huge_Opaque 1713 ns 1713 ns 401408
BM_StringAssignStr_Huge_Transparent 1704 ns 1704 ns 397312
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75211
Files:
libcxx/__string
libcxx/include/__string
libcxx/include/string
libcxx/string
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75211.246823.patch
Type: text/x-patch
Size: 9205 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200226/c54725fc/attachment.bin>
More information about the libcxx-commits
mailing list