llvm-capstone/libcxx/include
Dmitry Vyukov f8afc53d64
[libc++] Speed up classic locale (#72112)
Locale objects use atomic reference counting, which may be very
expensive in parallel applications. The classic locale is used by
default by all streams and can be very contended. But it's never
destroyed, so the reference counting is also completely pointless on the
classic locale. Currently ~70% of time in the parallel stringstream
benchmarks is spent in locale ctor/dtor. And the execution radically
slows down with more threads.

Avoid reference counting on the classic locale. With this change
parallel benchmarks start to scale with threads.

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>

```
                              │   baseline   │    optimized                            │
                              │    sec/op    │    sec/op      vs base                  │
Istream_numbers/0/threads:1      4.672µ ± 0%   4.419µ ± 0%     -5.42% (p=0.000 n=30+39)
Istream_numbers/0/threads:72   539.817µ ± 0%   9.842µ ± 1%    -98.18% (p=0.000 n=30+40)
Istream_numbers/1/threads:1      4.890µ ± 0%   4.750µ ± 0%     -2.85% (p=0.000 n=30+40)
Istream_numbers/1/threads:72     66.44µ ± 1%   10.14µ ± 1%    -84.74% (p=0.000 n=30+40)
Istream_numbers/2/threads:1      4.888µ ± 0%   4.746µ ± 0%     -2.92% (p=0.000 n=30+40)
Istream_numbers/2/threads:72     494.8µ ± 0%   410.2µ ± 1%    -17.11% (p=0.000 n=30+40)
Istream_numbers/3/threads:1      4.697µ ± 0%   4.695µ ± 5%          ~ (p=0.391 n=30+37)
Istream_numbers/3/threads:72     421.5µ ± 7%   421.9µ ± 9%          ~ (p=0.665 n=30)
Ostream_number/0/threads:1       183.0n ± 0%   141.0n ± 2%    -22.95% (p=0.000 n=30)
Ostream_number/0/threads:72    24196.5n ± 1%   343.5n ± 3%    -98.58% (p=0.000 n=30)
Ostream_number/1/threads:1       250.0n ± 0%   196.0n ± 2%    -21.60% (p=0.000 n=30)
Ostream_number/1/threads:72    16260.5n ± 0%   407.0n ± 2%    -97.50% (p=0.000 n=30)
Ostream_number/2/threads:1       254.0n ± 0%   196.0n ± 1%    -22.83% (p=0.000 n=30)
Ostream_number/2/threads:72      28.49µ ± 1%   18.89µ ± 5%    -33.72% (p=0.000 n=30)
Ostream_number/3/threads:1       185.0n ± 0%   185.0n ± 0%      0.00% (p=0.017 n=30)
Ostream_number/3/threads:72      19.38µ ± 4%   19.33µ ± 5%          ~ (p=0.425 n=30)
```
2023-11-27 07:00:21 +01:00
..
__algorithm [libc++] Add missing headers to the modulemap (#71127) 2023-11-27 00:14:59 +01:00
__atomic [libc++] Refactor atomic_{unsigned,signed}_lock_free (#73041) 2023-11-22 14:54:40 -05:00
__bit [libc++] Fix the rotate direction used in countl_zero() 2023-09-12 18:19:56 -04:00
__charconv [libc++][NFC] Update the remaining enable_ifs 2023-09-01 17:51:17 -07:00
__chrono [libc++][chrono] Adds tzdb_list implementation. 2023-09-06 20:48:07 +02:00
__compare [libc++] Make everything in namespace std have default type visibility and hidden visibility and remove _LIBCPP_ENUM_VIS 2023-08-19 15:16:04 -07:00
__concepts [libc++] Check formatting with clang-format 17 (#68928) 2023-10-12 14:30:33 -07:00
__condition_variable [libc++][NFC] Refactor __enable_if return types to defaulted template parameters 2023-09-01 17:52:31 -07:00
__coroutine [libc++][hardening][NFC] Introduce _LIBCPP_ASSERT_UNCATEGORIZED. 2023-06-28 15:10:31 -07:00
__debug_utils [libc++][hardening][NFC] Introduce _LIBCPP_ASSERT_UNCATEGORIZED. 2023-06-28 15:10:31 -07:00
__exception [libc++] Remove availability annotations which can never be triggered (#69226) 2023-11-01 23:56:43 +01:00
__expected [libc++] Fix UB in <expected> related to "has value" flag (#68552) (#68733) 2023-10-30 14:56:03 -04:00
__filesystem [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
__format [libc++] Implements Runtime format strings II. (#72543) 2023-11-24 17:30:33 +01:00
__functional [libc++] Unify __is_trivial_equality_predicate and __is_trivial_plus_operation into __desugars_to (#68642) 2023-11-23 13:55:55 -05:00
__fwd [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
__ios [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
__iterator [libc++] Make common_iterator's data member private (#72564) 2023-11-21 16:22:59 -05:00
__locale_dir/locale_base_api [libc++][Modules] locale fails to compile with clang modules when _LIBCPP_LOCALE__L_EXTENSIONS is undefined 2023-08-24 14:22:41 -07:00
__math [libc++][NFC] Replace typedefs with using in the math headers 2023-08-03 08:51:50 -07:00
__mdspan [libc++] mdspan - implement layout_stride (#69650) 2023-10-20 08:13:52 -06:00
__memory [libc++][NFC] Use __construct_at and __destroy_at instead of using preprocessor conditionals (#70866) 2023-11-26 20:47:03 +01:00
__memory_resource [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
__mutex [libc++][NFC] Introduce named states in std::call_once (#66289) 2023-09-15 10:14:13 -04:00
__numeric [libc++] Unify __is_trivial_equality_predicate and __is_trivial_plus_operation into __desugars_to (#68642) 2023-11-23 13:55:55 -05:00
__random [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
__ranges [libc++][hardening] Add _LIBCPP_ASSERT_NON_NULL to check for null pointers (#71428) 2023-11-07 16:12:15 -10:00
__stop_token [libc++] Implement std::condition_variable_any::wait[_for/until] overloads that take stop_token 2023-09-29 13:50:16 +01:00
__string [libc++] Use __is_pointer_in_range for char_traits checks (#72643) 2023-11-19 16:49:40 +01:00
__support libcxx: Bring back unsigned return from wcstoull_l 2023-07-08 13:54:30 +02:00
__system_error [libc++] Adds __throw_system_error overload. 2023-08-29 19:08:18 +02:00
__thread [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
__tuple [libc++] Merge _LIBCPP_FUNC_VIS, _LIBCPP_TYPE_VIS and _LIBCPP_EXCEPTION_ABI into _LIBCPP_EXPORTED_FROM_ABI 2023-06-15 08:56:45 -07:00
__type_traits [libc++] Unify __is_trivial_equality_predicate and __is_trivial_plus_operation into __desugars_to (#68642) 2023-11-23 13:55:55 -05:00
__utility [libc++] Speed up classic locale (#72112) 2023-11-27 07:00:21 +01:00
__variant [libc++][NFC] Replace _LIBCPP_STD_VER > x with _LIBCPP_STD_VER >= x 2023-02-15 16:52:25 +01:00
experimental [libc++] Add missing headers to the modulemap (#71127) 2023-11-27 00:14:59 +01:00
ext [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
__assert [libc++][hardening] Deprecate _LIBCPP_ENABLE_ASSERTIONS. 2023-07-14 16:58:47 -07:00
__availability [libc++][NFC] Refactor _LIBCPP_AVAILABILITY_HAS_* macros to always be defined (#71002) 2023-11-24 23:45:17 +01:00
__bit_reference [libc++] Optimize ranges::count for __bit_iterators 2023-10-06 22:58:41 +02:00
__config [libc++][NFC] Move QoI attributes into a single place inside <__config> (#70870) 2023-11-23 22:15:06 +01:00
__config_site.in [libc++][hardening] Rework macros for enabling the hardening mode. (#70575) 2023-11-08 09:10:00 -10:00
__hash_table [libc++] Re-apply "Remove UB in list, forward_list and __hash_table" 2023-10-13 08:03:22 -07:00
__locale [libc++] Speed up classic locale (#72112) 2023-11-27 07:00:21 +01:00
__mbstate_t.h [libc++] Include "bits/alltypes.h" to provide mbstate_t when using musl libc 2023-05-30 17:59:32 -07:00
__node_handle [libc++] Re-apply "Remove UB in list, forward_list and __hash_table" 2023-10-13 08:03:22 -07:00
__split_buffer [libc++][NFC] Refactor __enable_if return types to defaulted template parameters 2023-09-01 17:52:31 -07:00
__std_clang_module Implement syncstream (p0053) 2023-11-08 17:45:06 +01:00
__std_mbstate_t.h [libc++] cuchar redeclares ::mbstate_t when it's in its own clang module 2023-05-01 13:48:20 -05:00
__threading_support [libc++] Fix __threading_support when used with C11 threading (#66780) 2023-09-19 18:15:26 -04:00
__tree [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
__undef_macros Fixing conflicting macro definitions between curses.h and the standard library. 2023-07-06 17:21:08 +00:00
__verbose_abort [libc++][NFC] Refactor _LIBCPP_AVAILABILITY_HAS_* macros to always be defined (#71002) 2023-11-24 23:45:17 +01:00
algorithm [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
any [libc++] Remove alignment_of uses (#70591) 2023-10-31 10:24:44 -04:00
array [libc++][NFC] Refactor __enable_if return types to defaulted template parameters 2023-09-01 17:52:31 -07:00
atomic [libc++] Refactor atomic_{unsigned,signed}_lock_free (#73041) 2023-11-22 14:54:40 -05:00
barrier [libc++] add basic runtime assertions to <barrier> 2023-07-15 12:50:28 +02:00
bit [libc++] Fix the signature of std::rotl and std::rotr 2023-08-12 08:46:11 -07:00
bitset [libc++] Optimize ranges::count for __bit_iterators 2023-10-06 22:58:41 +02:00
cassert [libc++] Add missing __has_include checks for C headers not provided by libc++ 2022-11-23 09:50:14 -05:00
ccomplex
cctype [libc++] Diagnose when header search paths are set up incorrectly 2022-08-17 14:05:26 -04:00
cerrno [libc++] Diagnose when header search paths are set up incorrectly 2022-08-17 14:05:26 -04:00
cfenv [libc++] Diagnose when header search paths are set up incorrectly 2022-08-17 14:05:26 -04:00
cfloat [libc++] Diagnose when header search paths are set up incorrectly 2022-08-17 14:05:26 -04:00
charconv [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
chrono [libc++] Refactor node creation and destruction in list and forward_list (#65614) 2023-09-15 10:10:26 -04:00
cinttypes [libc++][NFC] Fix some standard-mandated includes comments 2022-09-27 21:11:53 +02:00
ciso646
climits [libc++] Remove libc++'s own <limits.h> (#65472) 2023-10-10 11:06:43 -07:00
clocale [libc++] Diagnose when header search paths are set up incorrectly 2022-08-17 14:05:26 -04:00
CMakeLists.txt [libc++] Speed up classic locale (#72112) 2023-11-27 07:00:21 +01:00
cmath [libc++][NFC] Refactor __enable_if return types to defaulted template parameters 2023-09-01 17:52:31 -07:00
codecvt [libc++] Removes codecvt. (#72496) 2023-11-24 17:34:30 +01:00
compare [libc++] Module fixes for __synth_three_way. 2023-04-07 18:54:09 +02:00
complex [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
complex.h [libc++] Only include_next C library headers when they exist 2022-11-17 10:30:20 -05:00
concepts [libc++] Granularize <type_traits> includes in <concepts> 2022-12-20 21:37:39 +01:00
condition_variable [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
coroutine [libc++] Granularize <type_traits> includes in <bit>, <numbers> and <coroutine> 2023-01-21 15:09:21 +01:00
csetjmp [libc++] Remove libc++'s own <setjmp.h> header (#68806) 2023-10-12 16:59:04 -07:00
csignal [libc++] Add missing __has_include checks for C headers not provided by libc++ 2022-11-23 09:50:14 -05:00
cstdarg [libc++] Add missing __has_include checks for C headers not provided by libc++ 2022-11-23 09:50:14 -05:00
cstdbool
cstddef [libc++][NFC] Refactor __enable_ifs in <cstddef> to be defaulted 2023-10-29 11:49:50 +01:00
cstdint [libc++] Diagnose when header search paths are set up incorrectly 2022-08-17 14:05:26 -04:00
cstdio [libc++] Remove _LIBCPP_HAS_NO_FGETPOS_FSETPOS (#72073) 2023-11-13 09:43:25 +01:00
cstdlib [libc++] Fixes disabling wide character. 2023-08-19 19:09:16 +02:00
cstring [libc++] Move constexpr <cstring> functions into their own headers and remove unused <cstring> includes 2023-02-21 16:56:29 +01:00
ctgmath
ctime [libc++][NFC] Replace _LIBCPP_STD_VER > x with _LIBCPP_STD_VER >= x 2023-02-15 16:52:25 +01:00
ctype.h [libc++] Only include_next C library headers when they exist 2022-11-17 10:30:20 -05:00
cuchar [libc++][cuchar] Declare std::c8rtomb and std::mbrtoc8 in <cuchar> if available. 2022-09-10 21:10:33 -04:00
cwchar [libc++] Forward to std::{,w}memchr in std::find 2023-05-25 07:59:50 -07:00
cwctype [libc++] Diagnose when header search paths are set up incorrectly 2022-08-17 14:05:26 -04:00
deque [NFC] Remove outdated comment (#72591) 2023-11-16 21:23:07 -05:00
errno.h [libc++] Only include_next C library headers when they exist 2022-11-17 10:30:20 -05:00
exception [libc++] Granularize <exception> 2023-03-12 22:19:41 +01:00
execution [libc++][PSTL] Add more specialized backend customization points 2023-05-11 13:54:28 -07:00
expected [libc++] Implement std::expected P0323R12 2022-12-14 15:43:42 +00:00
fenv.h [libc++] Only include_next C library headers when they exist 2022-11-17 10:30:20 -05:00
filesystem [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
float.h [libc++] Only include_next C library headers when they exist 2022-11-17 10:30:20 -05:00
format [libc++] Implements Runtime format strings II. (#72543) 2023-11-24 17:30:33 +01:00
forward_list [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
fstream [libc++][NFC] Refactor _LIBCPP_AVAILABILITY_HAS_* macros to always be defined (#71002) 2023-11-24 23:45:17 +01:00
functional [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
future [libc++][hardening] Add _LIBCPP_ASSERT_NON_NULL to check for null pointers (#71428) 2023-11-07 16:12:15 -10:00
initializer_list [libc++][NFC] Rename the constexpr macros 2022-08-19 15:35:02 +02:00
inttypes.h [libc++] Only include_next C library headers when they exist 2022-11-17 10:30:20 -05:00
iomanip [libc++] Add clang-tidy check for version checks 2023-03-08 15:17:25 +01:00
ios [libc++] Implement P2467R1: Support exclusive mode for fstreams 2023-11-17 17:27:30 -05:00
iosfwd Implement syncstream (p0053) 2023-11-08 17:45:06 +01:00
iostream [libc++] Merge _LIBCPP_FUNC_VIS, _LIBCPP_TYPE_VIS and _LIBCPP_EXCEPTION_ABI into _LIBCPP_EXPORTED_FROM_ABI 2023-06-15 08:56:45 -07:00
istream [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
iterator [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
latch [libc++] add basic runtime assertions to <latch> 2023-07-05 17:34:23 -04:00
libcxx.imp [libc++][NFC] Remove the old PSTL headers 2023-08-11 08:29:15 -07:00
limits [libc++] Implement P2614R2 (Deprecate numeric_limits::has_denorm) 2023-10-06 11:30:55 +02:00
list [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
locale [libc++][hardening] Add _LIBCPP_ASSERT_NON_NULL to check for null pointers (#71428) 2023-11-07 16:12:15 -10:00
locale.h [libc++] Only include_next C library headers when they exist 2022-11-17 10:30:20 -05:00
map Implement syncstream (p0053) 2023-11-08 17:45:06 +01:00
math.h [libc++] Add std::fpclassify overloads for floating-point. (#67913) 2023-10-05 21:18:02 +02:00
mdspan [libc++] Updates mdspan synopsis, 2023-11-25 14:45:21 +01:00
memory [libc++] LWG 3821 uses_allocator_construction_args should have overload for pair-like (#66939) 2023-10-09 13:50:27 +01:00
memory_resource [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
module.modulemap.in [libc++] Speed up classic locale (#72112) 2023-11-27 07:00:21 +01:00
mutex [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
new [libc++][NFC] Adjust synopsis for std::launder 2023-11-23 11:11:51 -05:00
numbers [libc++][NFC] Replace _LIBCPP_STD_VER > x with _LIBCPP_STD_VER >= x 2023-02-15 16:52:25 +01:00
numeric [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
optional [libc++][NFC] Use __construct_at and __destroy_at instead of using preprocessor conditionals (#70866) 2023-11-26 20:47:03 +01:00
ostream [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
print [libc++][print] Adds stdout functions. 2023-07-22 11:28:17 +02:00
queue [libc++][NFC] Refactor __enable_if return types to defaulted template parameters 2023-09-01 17:52:31 -07:00
random [libc++] Remove <cstdlib> includes 2023-04-09 02:52:33 +02:00
ranges [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
ratio [libc++] "Implements" new SI prefixis. 2023-06-19 17:04:35 +02:00
regex [libc++][NFC] Update the remaining enable_ifs 2023-09-01 17:51:17 -07:00
scoped_allocator [libc++][NFC] Update the remaining enable_ifs 2023-09-01 17:51:17 -07:00
semaphore [libc++] Remove unused include in __threading_support 2023-09-06 09:39:39 -04:00
set [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
shared_mutex [libc++] Remove availability annotations which can never be triggered (#69226) 2023-11-01 23:56:43 +01:00
source_location [libc++] Don't try to provide source_location on AppleClang 1403 2023-03-28 09:53:07 -04:00
span [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
sstream [libc++][NFC] Refactor _LIBCPP_AVAILABILITY_HAS_* macros to always be defined (#71002) 2023-11-24 23:45:17 +01:00
stack [libc++][NFC] Refactor __enable_if return types to defaulted template parameters 2023-09-01 17:52:31 -07:00
stdatomic.h [libc++][NFC] Replace _LIBCPP_STD_VER > x with _LIBCPP_STD_VER >= x 2023-02-15 16:52:25 +01:00
stdbool.h [libc++][NFC] Consistently use newline between license and include guard 2022-11-25 10:25:17 -05:00
stddef.h Revert "[libc++] Remove workarounds for systems that used to require __need_XXX macros" 2022-11-22 20:46:38 +09:00
stdexcept [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
stdint.h [libc++] Only include_next C library headers when they exist 2022-11-17 10:30:20 -05:00
stdio.h [libc++] Wipe some more macros that do not belong in C++ forwarding headers 2023-09-07 13:32:26 -04:00
stdlib.h [libc++] Remove Solaris related code 2023-05-05 08:39:51 -04:00
stop_token [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
streambuf Implement syncstream (p0053) 2023-11-08 17:45:06 +01:00
string [libc++] Removes basic_string::reserve(). (#73354) 2023-11-25 13:56:40 +01:00
string_view [libc++][hardening] Add _LIBCPP_ASSERT_NON_NULL to check for null pointers (#71428) 2023-11-07 16:12:15 -10:00
string.h [libc++] Remove Solaris related code 2023-05-05 08:39:51 -04:00
strstream [libc++] Merge _LIBCPP_FUNC_VIS, _LIBCPP_TYPE_VIS and _LIBCPP_EXCEPTION_ABI into _LIBCPP_EXPORTED_FROM_ABI 2023-06-15 08:56:45 -07:00
syncstream Implement syncstream (p0053) 2023-11-08 17:45:06 +01:00
system_error [libc++] Move __errc to __system_error/errc.h 2023-04-10 19:23:42 +02:00
tgmath.h [libc++] Only include_next C library headers when they exist 2022-11-17 10:30:20 -05:00
thread [libc++] implement std::jthread 2023-09-16 19:54:19 +01:00
tuple [libc++] Simplify the tuple constructor overload set 2023-10-16 19:49:13 +02:00
type_traits [libc++] Untangles invoke. 2023-05-24 07:51:27 +02:00
typeindex [libc++][NFC] Replace _LIBCPP_STD_VER > x with _LIBCPP_STD_VER >= x 2023-02-15 16:52:25 +01:00
typeinfo [libc++] Remove availability annotations which can never be triggered (#69226) 2023-11-01 23:56:43 +01:00
uchar.h [libc++] cuchar redeclares ::mbstate_t when it's in its own clang module 2023-05-01 13:48:20 -05:00
unordered_map [libc++] Re-apply "Remove UB in list, forward_list and __hash_table" 2023-10-13 08:03:22 -07:00
unordered_set [libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00
utility [libc++] Updates C++2b to C++23. 2023-05-23 18:44:41 +02:00
valarray [libc++][NFC] Refactor return type enable_ifs to defaulted template arguments 2023-08-15 12:19:21 -07:00
variant [libc++] Re-introduce special support for narrowing conversions to bool in variant (#73121) 2023-11-22 20:41:12 +01:00
vector [libc++] Optimize vector push_back to avoid continuous load and store of end pointer 2023-10-02 09:12:37 -04:00
version [libc++][NFC] Refactor _LIBCPP_AVAILABILITY_HAS_* macros to always be defined (#71002) 2023-11-24 23:45:17 +01:00
wchar.h [runtimes][NFC] Remove stray whitespace on extern C comments 2023-08-11 13:25:01 -04:00
wctype.h