-
Notifications
You must be signed in to change notification settings - Fork 14.1k
[libc++][format] Implements P3107R5 in <print>. #130500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: users/mordante/P3107R5-benchmarks
Are you sure you want to change the base?
[libc++][format] Implements P3107R5 in <print>. #130500
Conversation
✅ With the latest revision this PR passed the C/C++ code formatter. |
3efe358
to
4bd6795
Compare
The followup paper P3235R3 which is voted in as a DR changes the names foo_locking to foo_buffered. These changes have been applied in this patch. Before ------------------------------------------------------- Benchmark Time CPU Iterations ------------------------------------------------------- printf 71.3 ns 71.3 ns 9525175 print_string 226 ns 226 ns 3105850 print_stack 232 ns 232 ns 3026498 print_direct 530 ns 530 ns 1318447 After ------------------------------------------------------- Benchmark Time CPU Iterations ------------------------------------------------------- printf 70.6 ns 70.6 ns 9789585 print_string 222 ns 222 ns 3147678 print_stack 227 ns 227 ns 3084767 print_direct 474 ns 474 ns 1472786 Note: The performance of libc++'s std::print is still extemely slow compared to printf. Based on P3107R5 std::print should outperform printf. The main culprit is the call to isatty, which is resolved after implementing LWG4044 Confusing requirements for std::print on POSIX platforms Implements - P3107R5 - Permit an efficient implementation of ``std::print`` Implements parts of - P3235R3 std::print more types faster with less memory Fixes: #105435
071b6c1
to
7ab2024
Compare
7ab2024
to
4fcce8d
Compare
This was discovered when using this name in llvm#130500.
This was discovered when using this name in #130500.
fb15f9b
to
4b0bd31
Compare
4b0bd31
to
b190535
Compare
template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). | ||
_LIBCPP_HIDE_FROM_ABI inline void | ||
__vprint_nonunicode(FILE* __stream, string_view __fmt, format_args __args, bool __write_nl) { | ||
_LIBCPP_HIDE_FROM_ABI inline void __flockfile(FILE* __stream) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should take the opportunity to introduce a proper "platform layer" for these functions. Something similar to what we do in libcxx/include/__thread/support.h
or libcxx/include/__locale_dir/locale_base_api.h
, or libcxx/include/__atomic/support.h
. I think we might be able to grow this into something more generally useful for other parts of the library.
The followup paper P3235R3 which is voted in as a DR changes the names foo_locking to foo_buffered. These changes have been applied in this patch.
Before
Benchmark Time CPU Iterations
printf 71.3 ns 71.3 ns 9525175
print_string 226 ns 226 ns 3105850
print_stack 232 ns 232 ns 3026498
print_direct 530 ns 530 ns 1318447
After
Benchmark Time CPU Iterations
printf 70.6 ns 70.6 ns 9789585
print_string 222 ns 222 ns 3147678
print_stack 227 ns 227 ns 3084767
print_direct 474 ns 474 ns 1472786
Note: The performance of libc++'s std::print is still extemely slow compared to printf. Based on P3107R5 std::print should outperform printf. The main culprit is the call to isatty, which is resolved after implementing
LWG4044 Confusing requirements for std::print on POSIX platforms
Implements
std::print
Implements parts of
Fixes: #105435