Skip to content

Commit

Permalink
Update paper
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Mar 20, 2024
1 parent 371f2c4 commit 0e1bb3e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 18 deletions.
35 changes: 32 additions & 3 deletions papers/p3107.bs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ to address this shortcoming.
Changes since R3 {#changes3}
================

* Change `has_locking_formatter` to `enable_nonlocking_formatter_optimization`
and reverse the meaning.
* Changed `has_locking_formatter` to `enable_nonlocking_formatter_optimization`
and reverse the meaning per LEWG request.
* Added LEWG poll results for R3.

Changes since R2 {#changes2}
================

* Change the opt-in mechanism to use a namespace-scoped variable template
* Changed the opt-in mechanism to use a namespace-scoped variable template
instead of a nested member to prevent the inheritance issue.

Changes since R1 {#changes1}
Expand All @@ -54,6 +55,34 @@ Changes since R0 {#changes0}
call `format`.
* Fixed typos.

Polls {#polls}
=====

LEWG poll results for R3:

**POLL**: Change `has_locking_formatter` to
`enable_nonlocking_formatter_optimization` and reverse the boolean polarity

```text
SF F N A SA
4 10 3 0 0
```

**Outcome**: Consensus

**POLL**: Modify P3107R3 (Permit an efficient implementation of std::print) by
performing the modifications from the prior poll, and then send the revised
paper to LWG for C++26 with a recommendation that implementations backport the
change, classified as B2 (bug fix), to be confirmed with a Library Evolution
electronic poll.

```text
SF F N A SA
10 7 1 1 1
```

**Outcome**: Consensus

Problems {#problem}
========

Expand Down
49 changes: 34 additions & 15 deletions papers/p3107.html
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@
</style>
<meta content="Bikeshed version 4416b18d5, updated Tue Jan 2 15:52:39 2024 -0800" name="generator">
<link href="https://isocpp.org/favicon.ico" rel="icon">
<meta content="3f45e6a551dfa895e750539ab52eef862deed16c" name="revision">
<meta content="371f2c442e2289f21a6fecfab5109e7af4291bd6" name="revision">
<style>/* Boilerplate: style-autolinks */
.css.css, .property.property, .descriptor.descriptor {
color: var(--a-normal-text);
Expand Down Expand Up @@ -2109,12 +2109,13 @@ <h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
<li><a href="#changes2"><span class="secno">3</span> <span class="content">Changes since R2</span></a>
<li><a href="#changes1"><span class="secno">4</span> <span class="content">Changes since R1</span></a>
<li><a href="#changes0"><span class="secno">5</span> <span class="content">Changes since R0</span></a>
<li><a href="#problem"><span class="secno">6</span> <span class="content">Problems</span></a>
<li><a href="#proposal"><span class="secno">7</span> <span class="content">Proposal</span></a>
<li><a href="#perf"><span class="secno">8</span> <span class="content">Performance</span></a>
<li><a href="#impl"><span class="secno">9</span> <span class="content">Implementation</span></a>
<li><a href="#wording"><span class="secno">10</span> <span class="content">Wording</span></a>
<li><a href="#ack"><span class="secno">11</span> <span class="content">Acknowledgements</span></a>
<li><a href="#polls"><span class="secno">6</span> <span class="content">Polls</span></a>
<li><a href="#problem"><span class="secno">7</span> <span class="content">Problems</span></a>
<li><a href="#proposal"><span class="secno">8</span> <span class="content">Proposal</span></a>
<li><a href="#perf"><span class="secno">9</span> <span class="content">Performance</span></a>
<li><a href="#impl"><span class="secno">10</span> <span class="content">Implementation</span></a>
<li><a href="#wording"><span class="secno">11</span> <span class="content">Wording</span></a>
<li><a href="#ack"><span class="secno">12</span> <span class="content">Acknowledgements</span></a>
<li>
<a href="#references"><span class="secno"></span> <span class="content">References</span></a>
<ol class="toc">
Expand All @@ -2134,12 +2135,14 @@ <h2 class="heading settled" data-level="1" id="intro"><span class="secno">1. </s
<h2 class="heading settled" data-level="2" id="changes3"><span class="secno">2. </span><span class="content">Changes since R3</span><a class="self-link" href="#changes3"></a></h2>
<ul>
<li data-md>
<p>Change <code class="highlight"><c- n>has_locking_formatter</c-></code> to <code class="highlight"><c- n>enable_nonlocking_formatter_optimization</c-></code> and reverse the meaning.</p>
<p>Changed <code class="highlight"><c- n>has_locking_formatter</c-></code> to <code class="highlight"><c- n>enable_nonlocking_formatter_optimization</c-></code> and reverse the meaning per LEWG request.</p>
<li data-md>
<p>Added LEWG poll results for R3.</p>
</ul>
<h2 class="heading settled" data-level="3" id="changes2"><span class="secno">3. </span><span class="content">Changes since R2</span><a class="self-link" href="#changes2"></a></h2>
<ul>
<li data-md>
<p>Change the opt-in mechanism to use a namespace-scoped variable template
<p>Changed the opt-in mechanism to use a namespace-scoped variable template
instead of a nested member to prevent the inheritance issue.</p>
</ul>
<h2 class="heading settled" data-level="4" id="changes1"><span class="secno">4. </span><span class="content">Changes since R1</span><a class="self-link" href="#changes1"></a></h2>
Expand All @@ -2166,7 +2169,23 @@ <h2 class="heading settled" data-level="5" id="changes0"><span class="secno">5.
<li data-md>
<p>Fixed typos.</p>
</ul>
<h2 class="heading settled" data-level="6" id="problem"><span class="secno">6. </span><span class="content">Problems</span><a class="self-link" href="#problem"></a></h2>
<h2 class="heading settled" data-level="6" id="polls"><span class="secno">6. </span><span class="content">Polls</span><a class="self-link" href="#polls"></a></h2>
<p>LEWG poll results for R3:</p>
<p><strong>POLL</strong>: Change <code class="highlight"><c- n>has_locking_formatter</c-></code> to <code class="highlight"><c- n>enable_nonlocking_formatter_optimization</c-></code> and reverse the boolean polarity</p>
<pre class="language-text highlight">SF F N A SA
4 10 3 0 0
</pre>
<p><strong>Outcome</strong>: Consensus</p>
<p><strong>POLL</strong>: Modify P3107R3 (Permit an efficient implementation of std::print) by
performing the modifications from the prior poll, and then send the revised
paper to LWG for C++26 with a recommendation that implementations backport the
change, classified as B2 (bug fix), to be confirmed with a Library Evolution
electronic poll.</p>
<pre class="language-text highlight">SF F N A SA
10 7 1 1 1
</pre>
<p><strong>Outcome</strong>: Consensus</p>
<h2 class="heading settled" data-level="7" id="problem"><span class="secno">7. </span><span class="content">Problems</span><a class="self-link" href="#problem"></a></h2>
<p>As reported in <a data-link-type="biblio" href="#biblio-lwg4042" title="LWG Issue 4042: `std::print` should permit an efficient implementation">[LWG4042]</a>, <code class="highlight"><c- n>std</c-><c- o>::</c-><c- n>print</c-></code>/<code class="highlight"><c- n>std</c-><c- o>::</c-><c- n>vprint</c-><c- o>*</c-></code> is currently defined in
terms of formatting into a temporary <code class="highlight"><c- n>std</c-><c- o>::</c-><c- n>string</c-></code>, e.g. <a href="https://eel.is/c++draft/print.fun">[print.fun</a>]:</p>
<blockquote>
Expand All @@ -2188,7 +2207,7 @@ <h2 class="heading settled" data-level="6" id="problem"><span class="secno">6. <
allocations, making <code class="highlight"><c- n>std</c-><c- o>::</c-><c- n>print</c-></code> unsuitable for resource-constrained
applications creating incentives for continued use of unsafe APIs. In the direct
method, there are usually no memory allocations.</p>
<h2 class="heading settled" data-level="7" id="proposal"><span class="secno">7. </span><span class="content">Proposal</span><a class="self-link" href="#proposal"></a></h2>
<h2 class="heading settled" data-level="8" id="proposal"><span class="secno">8. </span><span class="content">Proposal</span><a class="self-link" href="#proposal"></a></h2>
<p>The current paper proposes expressing the desire to have non-interleaved
output in a way that permits a more efficient implementation similar
to <code class="highlight"><c- n>printf</c-></code>’s. It is based on the locking mechanism provided by C streams,
Expand Down Expand Up @@ -2372,7 +2391,7 @@ <h2 class="heading settled" data-level="7" id="proposal"><span class="secno">7.
<c- p>};</c->
</pre>
<p>The advantage of the variable template is that it doesn’t propagate when one <code class="highlight"><c- n>formatter</c-></code> is inherited from another.</p>
<h2 class="heading settled" data-level="8" id="perf"><span class="secno">8. </span><span class="content">Performance</span><a class="self-link" href="#perf"></a></h2>
<h2 class="heading settled" data-level="9" id="perf"><span class="secno">9. </span><span class="content">Performance</span><a class="self-link" href="#perf"></a></h2>
<p>The following benchmark demonstrates the difference in performance between
different implementation strategies using the reference implementation of <code class="highlight"><c- n>print</c-></code> from <a data-link-type="biblio" href="#biblio-fmt" title="The {fmt} library">[FMT]</a>. This benchmark is based on the one from <a data-link-type="biblio" href="#biblio-p2093" title="Formatted output">[P2093]</a> but
modified to avoid the small string optimization effects. It formats a simple
Expand Down Expand Up @@ -2476,10 +2495,10 @@ <h2 class="heading settled" data-level="8" id="perf"><span class="secno">8. </sp
faster than writing to a stack-allocated buffer on this benchmark.</p>
<p>Preliminary testing in libstc++ showed ~25% improvement compared to the
existing implementation.</p>
<h2 class="heading settled" data-level="9" id="impl"><span class="secno">9. </span><span class="content">Implementation</span><a class="self-link" href="#impl"></a></h2>
<h2 class="heading settled" data-level="10" id="impl"><span class="secno">10. </span><span class="content">Implementation</span><a class="self-link" href="#impl"></a></h2>
<p>This proposal has been implemented in the open-source {fmt} library (<a data-link-type="biblio" href="#biblio-fmt" title="The {fmt} library">[FMT]</a>)
bringing major performance improvements.</p>
<h2 class="heading settled" data-level="10" id="wording"><span class="secno">10. </span><span class="content">Wording</span><a class="self-link" href="#wording"></a></h2>
<h2 class="heading settled" data-level="11" id="wording"><span class="secno">11. </span><span class="content">Wording</span><a class="self-link" href="#wording"></a></h2>
<p>Update the value of the feature-testing macro <code class="highlight"><c- n>__cpp_lib_print</c-></code> to the date of
adoption in <a href="https://eel.is/c++draft/version.syn">[version.syn</a>].</p>
<p>Modify <a href="https://eel.is/c++draft/format.syn">[format.syn</a>] as
Expand Down Expand Up @@ -2598,7 +2617,7 @@ <h2 class="heading settled" data-level="10" id="wording"><span class="secno">10.
<p>[<em>Note 1</em>: Specializations such as <code class="highlight"><c- n>formatter</c-><c- o>&lt;</c-><c- b>wchar_t</c-><c- p>,</c-> <c- b>char</c-><c- o>></c-></code> and <code class="highlight"><c- n>formatter</c-><c- o>&lt;</c-><c- k>const</c-> <c- b>char</c-><c- o>*</c-><c- p>,</c-> <c- b>wchar_t</c-><c- o>></c-></code> that would require implicit multibyte /
wide string or character conversion are disabled. — end note]</p>
<p>...</p>
<h2 class="heading settled" data-level="11" id="ack"><span class="secno">11. </span><span class="content">Acknowledgements</span><a class="self-link" href="#ack"></a></h2>
<h2 class="heading settled" data-level="12" id="ack"><span class="secno">12. </span><span class="content">Acknowledgements</span><a class="self-link" href="#ack"></a></h2>
<p>Thanks to Jonathan Wakely for implementing the proposal in libstdc++,
providing benchmark results and suggesting various improvements to the paper.</p>
<p>Thanks to Ben Craig for proposing to make user-defined formatters opt into the
Expand Down

0 comments on commit 0e1bb3e

Please sign in to comment.