[libc++][format] Implements P3107R5 in <print>. #130500
Open
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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::printImplements parts of
Fixes: #105435