Martijn Vels
2bad222680
Add optimization to basic_string::assign for compile-time known constant values.
Summary:
This change optimizes the assign() methods for string where either the contents or lengths are compile time known constants. For small strings (< min_cap) we can execute the assignment entirely inline. For strings up to 128 bytes we allow the compiler to efficiently inline the copy operation after we call the offline __resize<>() method. Short / long branches are taken at the call site for better branch prediction and allowing FDO optimizations.
Benchmarks (unstable / google perflab):
```
name old time/op new time/op delta
BM_StringAssignAsciiz_Empty_Opaque 5.69ns ± 7% 5.97ns ± 7% ~ (p=0.056 n=5+5)
BM_StringAssignAsciiz_Empty_Transparent 5.39ns ± 7% 0.79ns ± 8% -85.36% (p=0.008 n=5+5)
BM_StringAssignAsciiz_Small_Opaque 11.2ns ± 5% 11.0ns ± 6% ~ (p=0.548 n=5+5)
BM_StringAssignAsciiz_Small_Transparent 10.1ns ± 7% 1.0ns ± 8% -89.76% (p=0.008 n=5+5)
BM_StringAssignAsciiz_Large_Opaque 23.5ns ± 7% 23.8ns ± 7% ~ (p=0.841 n=5+5)
BM_StringAssignAsciiz_Large_Transparent 21.4ns ± 7% 12.7ns ± 7% -40.83% (p=0.008 n=5+5)
BM_StringAssignAsciiz_Huge_Opaque 336ns ± 4% 327ns ± 7% ~ (p=0.421 n=5+5)
BM_StringAssignAsciiz_Huge_Transparent 331ns ± 5% 324ns ± 7% ~ (p=0.548 n=5+5)
BM_StringAssignAsciizMix_Opaque 13.6ns ±10% 13.7ns ± 9% ~ (p=0.690 n=5+5)
BM_StringAssignAsciizMix_Transparent 12.9ns ± 8% 3.6ns ± 8% -71.82% (p=0.008 n=5+5)
```
Reviewers: EricWF, #libc!
Subscribers: jfb, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D82221
2020-06-29 14:34:34 -04:00
..
2019-10-23 11:19:19 -07:00
2019-12-12 21:09:08 -05:00
2020-01-29 22:37:11 +02:00
2020-02-19 12:02:06 -05:00
2019-01-19 10:56:40 +00:00
2019-01-19 10:56:40 +00:00
2020-06-25 16:33:30 -04:00
2020-05-29 06:14:30 -04:00
2019-10-23 08:08:57 -07:00
2019-01-19 10:56:40 +00:00
2020-03-10 17:45:39 -04:00
2020-02-20 12:22:21 -05:00
2019-01-19 10:56:40 +00:00
2019-12-16 18:38:58 -05:00
2020-01-15 13:38:01 +01:00
2020-04-06 13:38:16 -07:00
2019-12-13 15:42:07 -05:00
2019-04-24 09:43:44 +00:00
2019-01-19 10:56:40 +00:00
2019-12-16 18:38:58 -05:00
2019-01-19 10:56:40 +00:00
2019-01-19 10:56:40 +00:00
2020-06-29 14:34:34 -04:00
2020-05-21 13:48:59 +01:00
2019-12-16 18:38:58 -05:00
2019-09-30 20:55:30 +00:00
2019-01-19 08:50:56 +00:00
2019-11-18 01:49:32 -05:00
2019-06-19 16:33:28 +00:00
2020-06-01 16:37:39 -04:00
2020-06-01 14:30:13 -07:00
2020-04-06 18:07:26 -04:00
2020-05-28 14:31:21 -04:00
2019-07-01 19:59:34 +00:00
2019-01-19 10:56:40 +00:00
2019-01-19 10:56:40 +00:00
2019-01-19 10:56:40 +00:00
2019-01-19 10:56:40 +00:00
2019-01-19 10:56:40 +00:00
2019-01-19 10:56:40 +00:00
2020-05-22 16:11:44 -04:00
2020-06-09 13:43:13 -04:00
2019-01-19 08:50:56 +00:00
2019-01-19 10:56:40 +00:00
2019-01-19 10:56:40 +00:00
2019-01-19 10:56:40 +00:00
2020-06-26 15:13:04 -04:00
2020-05-25 22:28:21 +02:00
2020-03-17 18:59:54 +01:00
2020-06-18 10:22:50 -04:00
2020-05-07 13:51:07 -04:00
2019-01-19 10:56:40 +00:00
2020-04-08 18:00:13 -04:00
2019-01-19 10:56:40 +00:00
2019-01-19 10:56:40 +00:00
2019-01-19 10:56:40 +00:00
2019-01-19 10:56:40 +00:00
2019-01-19 10:56:40 +00:00
2020-04-04 01:38:41 +02:00
2019-01-19 10:56:40 +00:00
2020-04-16 12:51:08 -07:00
2019-11-18 12:19:58 -08:00
2019-01-19 08:50:56 +00:00
2019-01-19 10:56:40 +00:00
2019-11-18 12:19:58 -08:00
2019-01-19 10:56:40 +00:00
2019-01-19 10:56:40 +00:00
2019-01-19 10:56:40 +00:00
2020-05-02 14:04:50 +02:00
2019-01-19 10:56:40 +00:00
2020-03-17 18:59:54 +01:00
2019-08-06 21:11:24 +00:00
2019-03-29 16:03:57 +00:00
2020-03-17 18:59:54 +01:00
2019-01-19 10:56:40 +00:00
2020-05-02 14:04:50 +02:00
2019-09-16 19:26:41 +00:00
2020-05-19 17:15:28 -07:00
2020-03-17 18:59:54 +01:00
2019-05-29 16:01:36 +00:00
2019-06-20 15:36:32 +00:00
2019-05-29 16:01:36 +00:00
2020-03-17 18:59:54 +01:00
2019-01-19 10:56:40 +00:00
2019-01-19 10:56:40 +00:00
2019-08-20 18:21:06 +00:00
2020-06-16 13:47:47 -04:00
2020-04-06 18:07:26 -04:00
2019-07-01 16:13:31 +00:00
2019-01-19 10:56:40 +00:00
2020-05-02 14:04:50 +02:00
2019-05-29 16:01:36 +00:00
2019-01-19 10:56:40 +00:00
2020-05-02 14:04:50 +02:00
2020-05-08 21:52:27 +02:00
2020-06-08 09:49:21 -07:00
2020-06-19 14:25:02 +05:30
2019-11-11 10:27:48 -05:00
2020-02-25 11:42:08 -05:00
2020-06-19 10:49:44 -04:00
2019-12-21 01:26:24 -08:00
2019-06-27 18:40:55 +00:00
2019-09-25 18:56:54 +00:00
2019-11-18 01:49:32 -05:00
2020-03-17 15:56:16 -04:00
2019-01-19 10:56:40 +00:00
2020-06-25 15:34:51 -04:00
2019-01-19 10:56:40 +00:00
2020-04-06 18:07:26 -04:00
2020-05-02 14:04:50 +02:00
2019-01-19 10:56:40 +00:00
2019-08-04 07:13:43 +00:00
2020-05-20 14:34:21 -04:00
2019-02-01 21:59:27 +00:00
2019-05-29 16:01:36 +00:00
2019-01-19 10:56:40 +00:00
2020-04-04 01:38:41 +02:00
2020-03-17 18:59:54 +01:00
2019-06-20 15:36:32 +00:00
2019-01-19 10:56:40 +00:00
2020-05-08 21:52:27 +02:00
2019-01-19 10:56:40 +00:00
2020-06-29 14:34:34 -04:00
2019-09-25 18:56:54 +00:00
2019-01-19 08:50:56 +00:00
2019-01-19 10:56:40 +00:00
2020-03-17 18:59:54 +01:00
2019-01-19 10:56:40 +00:00
2020-06-10 12:40:43 -04:00
2019-10-28 18:04:41 -07:00
2020-05-18 14:06:32 +02:00
2019-01-19 10:56:40 +00:00
2020-05-29 06:14:30 -04:00
2020-05-02 14:04:50 +02:00
2020-05-02 14:04:50 +02:00
2019-09-30 20:55:30 +00:00
2019-12-12 21:09:08 -05:00
2020-06-18 07:21:42 -07:00
2020-06-18 13:51:12 -04:00
2020-06-19 10:49:44 -04:00
2020-06-25 19:27:32 -04:00
2019-01-19 10:56:40 +00:00