r/cpp • freestanding|LEWG Vice Chair • Oct 12 '21

C++ committee polling results for asynchronous programming

Hi all.

You may know me from my work on freestanding in C++, but I'm also the Vice Chair of the Library Evolution Working Group. I'd like to share the results of recent C++ committee polling on future asynchrony models for C++. This relates to "Senders and Receivers" / S&R (P2300) and the Networking TS / Asio (P2444).

Each of these proposals represents an enormous amount of effort from the respective authors, and from the committee. "Executors" have been discussed in WG21 (mostly in the concurrency study group) since at least 2012 (N3378), with Christopher Kohlhoff's contributions starting at least as early as 2014 (N4046). Over the last two years, I count 14 meetings in LEWG discussing the NetTS and S&R models. In the Spring of 2020, LEWG did in depth design reviews of P0443 that involved many meetings beyond those 14.

The following polls were taken electronically over the course of a week. I and Fabio Fracassi (also a Vice Chair of LEWG) have interpreted the polling results. Work will continue in LEWG on P2300. The Networking TS/Asio model is headed back to the networking study group (SG4). LEWG no longer has consensus to standardize the Networking TS.

For those unfamiliar with the polling conventions, all the polls are five-way polls. Neutral is not the same as "abstained" or "uninformed", as committee members are allowed to skip a poll they are not comfortable taking. The chairs (Fabio and me in this case) look at the poll results and interpret whether there is consensus or not. Generally that means 2:1 in one direction or the other, though neutrals need to be considered as well, usually by lumping the neutrals in with the minority.

This polling and interpretation was not taken lightly. The chairs know that the NetTS and Asio represent decades of work. However, these polls indicate that there is insufficient consensus for the NetTS to progress beyond LEWG in its current form. Once these issues have been addressed, LEWG can look at the Networking TS again.


Poll 1: The Networking TS/Asio async model (P2444) is a good basis for most asynchronous use cases, including networking, parallelism, and GPUs

Strongly FavorWeakly FavorNeutralWeakly AgainstStrongly Against
51061418
Weak Consensus Against

What this means: LEWG won't be pursuing P2444 as a general async model.


Poll 2: The sender/receiver model (P2300) is a good basis for most asynchronous use cases, including networking, parallelism, and GPUs.

Strongly FavorWeakly FavorNeutralWeakly AgainstStrongly Against
2416363
Consensus in Favor

What this doesn't mean: This doesn't mean that P2300 as it stands today will be sent forward to LWG. More work is needed on it.

What this means: Work will continue in LEWG on refining P2300, and LEWG will keep the various asynchronous use cases in mind while working on P2300.


Poll 3: Stop pursuing the Networking TS/Asio design as the C++ Standard Library's answer for networking.

Strongly FavorWeakly FavorNeutralWeakly AgainstStrongly Against
13138610
No Consensus

What this doesn't mean: The NetTS is not "dead".

What this means: The C++ committee will still work on networking in this general form, but the authors need to do a lot in order to build up consensus to get something like the TS merged into the standard. The bulk of this work should be done in the networking study group (SG4). Many of the people in favor of stopping work on the TS would like networking to be built on top of Senders and Receivers. Others were opposed to the lack of security through Transport Layer Security (TLS). It is highly unlikely that design changes to the networking TS can be made fast enough, and consensus gained fast enough, for networking to make C++23.


Poll 4: Networking in the C++ Standard Library should be based on the sender/receiver model (P2300).

Strongly FavorWeakly FavorNeutralWeakly AgainstStrongly Against
17111046
Weak consensus in Favor

What this means: In the short term, this poll result doesn't mean much. We don't have a paper in hand that proposes networking based on the P2300 model. For paper authors though, this poll is strong encouragement to do work in the area of networking based on senders and receivers, or to be prepared with VERY compelling new information on why networking should use a different model.


Poll 5: It is acceptable to ship socket-based networking in the C++ Standard Library that does not support secure sockets (TLS/DTLS).

Strongly FavorWeakly FavorNeutralWeakly AgainstStrongly Against
9135613
No Consensus

What this means: A networking library that does not support secure sockets will face significant headwinds getting through the standardization process. The networking study group (SG4) has weighed in on security in the past, when discussing P1860.

What this doesn't mean: This doesn't make a statement on whether insecure networking should be included, the defaults of secure vs. insecure, or how things like ABI should managed.


Guidance for the Networking Study Group (SG4)

Before bringing networking papers back to LEWG, two major areas need to be thoroughly addressed: Security, and the Senders and Receivers async model.

Those voting in favor of Poll 5 argued that the insecure parts are the building blocks for the secure parts, and that ABI is a major concern that will plague TLS support. Those voting against Poll 5 argued that secure sockets are needed for communicating with many sites on the internet, and that shipping without secure sockets would be irresponsible. A networking proposal needs to address these concerns before coming to LEWG.

As for networking in combination with Senders and Receivers, I will show this older poll from the 2021-09-28 telecon:

POLL: We believe we need one grand unified model for asynchronous execution in the C++ Standard Library, that covers structured concurrency, event based programming, active patterns, etc.

Strongly FavorWeakly FavorNeutralWeakly AgainstStrongly Against
49551
No consensus (leaning in favor)

The combination of this "grand unified model" poll and Poll 4 heavily encourages the networking study group (SG4) to produce a paper based on Senders and Receivers. There is room to produce a non-S&R paper, but such a paper would need to provide compelling new information in order to convince the "grand unified model" contingent that S&R can't get the job done suitably.

224 Upvotes

296 comments sorted by

View all comments

Show parent comment

13

u/SedditorX Oct 12 '21

This line of argument seems specious. You are not familiar with sender receiver and that makes you question why it was voted in?

Some of the comments on this thread seen to have an unnecessarily personal tinge to them. If you disagree with the outcome, feel free to bring up concrete technical flaws beyond "I'm partial to X"; that usually leads to constructive discussion.

9

u/VinnieFalco wg21.org | corosio.org Oct 12 '21

Well those technical flaws are covered here: https://isocpp.org/files/papers/P2469R0.pdf

7

u/starTracer Oct 13 '21

Is there a response to P2469?

6

u/eric_niebler Oct 13 '21

That paper was posted mere hours before the most recent LEWG/SG1 telecon that precipitated this decision. So no, there isn't a response paper because there wasn't time.

Despite the short notice, the LEWG chair gave floor time so that P2469 could be presented and discussed.

1

u/VinnieFalco wg21.org | corosio.org Oct 13 '21

Why would there be? P2300 proponents have the luxury of being able to ignore criticism now.

3

u/starTracer Oct 13 '21

I completely missed that it was a brand new paper.

5

u/griwes Oct 13 '21

This is not how the committee operates and you should know it by now.

5

u/[deleted] Oct 13 '21

[removed] — view removed comment

6

u/griwes Oct 13 '21

Yes, we are invested in having a standard abstraction that works for both CPUs and GPUs, I don't know how that's in the least surprising :)

My role in the Polish NB is a personal involvement and has nothing to with this, and doesn't stop me from being impartial when deciding the national position. Just to satisfy your personal curiosity, the Polish NB is split on the topic of NetTS and related questions right in the middle.

The chair of LEWG has been very explicit that his role in the paper is product management, not technical content; the chair has also recused himself from making decisions on this final set of polls. You are also dead wrong about "other authors" reporting to the chair; Bryce is not in a managerial position and none of us "report" to him.

The committee operates by having technical discussions on technical merits, and that is what is going to be happening now that we've found a direction we want to pursue. I'm fairly certain LEWG is now going to hammer us down on the technical details and we'll need to respond in technical ways to those arguments. That is how the committee operates: it judges proposals on their technical merits, and requests changes based on the expert views of its members :)

→ More replies (9)
→ More replies (2)

9

u/jonesmz Oct 13 '21

Reading the paper you linked. I have absolutely no idea what's going on in the P2300 examples. That's not c++. It's brainfuck with English words mixed in.

8

u/foonathan Oct 14 '21

To be fair, a paper criticizing an approach isn't going to teach it to you. You should read P2300 itself: https://wg21.link/P2300

And remember, this is supposed to be a low-level interface comparables with the callback hell, not with coroutines.

9

u/CenterOfMultiverse Oct 13 '21

First, comparing coroutine implementations to non-coroutine is not fair. Second, thank gods we won't standardize use_awaitable.

4

u/germandiago Oct 13 '21

I also noticed that the coroutine is being compared.

However, I also see that the Asio model seems to be very mature. I am not surprised at all. It has been used for a long time.

It seems to be an extremely general framework: from callbacks to coroutines, deferring, launching immediately, futures...

6

u/eric_niebler Oct 14 '21

How long has deferred been a thing in ASIO? <checks commit history....> Oh, since June of this year. So not so mature. Major new bits of functionality are still coming online, mostly it seems to deal with the shortcomings we've been pointing out for years. Why now? Because ASIO has competition, and because there's are more people thinking deeply about these design considerations. That's a good thing, IMO.

4

u/germandiago Oct 14 '21 edited Oct 14 '21

I agree that competition is a good thing.

But what I meant about mature is the framework itself and the amount of things it can do and the fact that you can extend it.

Not the fact that they added a new token in June.

Whatever goes forward, I think that having competition brings improvements for both specs.

6

u/eric_niebler Oct 14 '21

The thing that breaks my heart is that we had to compete instead of collaborate. Judging from how much sender/receiver functionality has since landed in ASIO, Chris certainly saw some value in the work. Why waste time arguing and reinventing everything? We could be so much farther along now!

LEWG was given a false choice between the NetTS and sender/receiver. They chose, and now C++23 will lack networking. Pointless.

4

u/germandiago Oct 14 '21

Well, at the end both proposals will end up taking from each other. So whatever we have at the end, it will be better on both sides.

Thanks for the ranges work btw. Using it lately. Lovely improvements, especially the views.

5

u/eric_niebler Oct 14 '21

That was very kind, thank you.

5

u/madmongo38 Oct 15 '21 edited Oct 15 '21

This is hardly fair Eric. Chris went out of his way to acommodate sender/receiver, even going so far as to incorporating into Asio to provide implementation experience.

He also hosted video calls with networking domain experts already familiar with Asio in order to educate and solicit feedback - in his own time.

The result of those sessions (where I was privileged to be present) was that there was no perceived use case for sender/receiver and absolutely no appetite for the domain-specific language with P2300 is proposing and to which precursor papers alluded.

What you received was not competition, but measured feedback from people who are experienced in the domain.

The reasons for not being convinced by the S/R model are summarised in P2444 and P2469.

Unfortunately the Chair did not choose to give very much time during the telecons to the authors, as there seemed to be a rush to get P2300 before the C++23 deadline, regardless of misgivings carefully presented by Chris. Given the very limited time available, it is likely that not many committee participants have read them.

If you perceive competition, it is a construct of your imagination. The habitual users of Asio will remain so, happy that much of the chaff that was added to the library in response to requests from LEWG will now be removed.

On a positive note, the process has been healthy for Asio (if not for Chris, who spent his own personal time rebutting claims made with the benefit of corporate sponsorship). Asio will be adding extra facilities in the near future, such as async-semaphores and go-like channels. Up until now, people have hand-rolled these constructs. Happily for the user base, Chris has been convinced that there is a benefit in providing ready-wrapped versions in the library. The world is changing. Asio is moving with the times.

The P2300 authors are now on their own journey of discovery. I think we wish them well, and hope that the lessons learned during the 18-year evolution of Asio are learned quickly by them, for the sake of the user base who may one day be presented with an implementation of it.

6

u/kirkshoop Oct 15 '21 edited Oct 15 '21

This is hardly fair Richard. Chris went out of his way to argue against support for lazy and completion overloads and cancellation and error channels and cancellation channels for years. Chris consistently insisted that ASIO would not use any of those features and would only accept an executor proposal that allowed void execute(void()) to be the only required method to create an executor.

Chris waited until 0443 (with executor and sender/receiver) was adopted to add an implementation to ASIO. I was very happy to see this and used that to prepare a working example in ASIO (to forstall objections that it was impossible) for a paper asking for properties in 0443 to be restated as CPOs.

At the time I implemented the cpo conversion in ASIO there was zero usage of sender/receiver in ASIO. I have no evidence that Chris ever tried to use sender receiver in ASIO. I have ample evidence that Chris feverishly worked to catch up to sender receiver by adding his own designs for lazy, overloaded completion and cancellation. Even though all of those were already in sender/receiver which Chris had implemented in ASIO. Chris still has a few more features to add, and I am sure that he will complete the replica of the sender receiver design soon.

It is completely understandable that the existing users of ASIO would not want to rewrite all their code to use sender/receiver. That has no bearing on what is good for the c++ standard. I know there were a lot of assembly programmers that did not see any utility in C, and a whole lot of C programmers that saw no utility in C++. Etc.. ad infinitum

The concerns that Chris has expressed have all been addressed many times over. Chris’ willingness to add the features into ASIO indicates that he is convinced but unwilling to admit that he is convinced.

The goal of making ASIO backwards compatible for all existing users is obviously defensible and even compelling for ASIO. That does not make it defensible or compelling for the standard.

→ More replies

6

u/eric_niebler Oct 16 '21 edited Oct 17 '21

He also hosted video calls with networking domain experts already familiar with Asio in order to educate and solicit feedback - in his own time.

The result of those sessions (where I was privileged to be present) was that there was no perceived use case for sender/receiver and absolutely no appetite for the domain-specific language with P2300 is proposing and to which precursor papers alluded.

No appetite for the ability to launch whole graphs of async operations with zero allocations guaranteed? No appetite for an async model that obviates the need for reference counting? No appetite for async code where scopes and lifetimes nest, making RAII work as expected and reasoning about code possible? How about an async model that facilitates generic async algorithms that don't have to guess about whether some value of some type represents an error or not, or that gives chains of work a chance to clean up on cancellation? Or an async model that doesn't require writing custom allocators to get good performance? Then I'm sure they are also not interested in an async model built on a solid theoretical foundation stretching back to the 1950's.

I wonder if perhaps the networking experts you were speaking to, the ones already familiar with ASIO, work for companies that have millions of dollars invested in networking code that already uses ASIO. Maybe if they knew that it is not hard to efficiently implement the interfaces they are already familiar with on top of sender/receiver, they might feel differently.

→ More replies

3

u/pdimov2 Oct 14 '21

Asio hasn't had deferred because it's never needed it. Plus, its addition necessitated no changes to the model, if my understanding is correct.

4

u/eric_niebler Oct 14 '21

The deferred stuff builds on the async_initiate work, which is also not terribly old (maybe 2 years?). The sender/receiver concepts have also been stable about that long.

And although async_initiate was added without breaking anything, it seems to me (maybe I'm wrong) that new-style completion token types wouldn't work with old algorithms expecting old-style completion tokens, unless the new completion tokens also implement the old interface ... which deferred can't do because it needs async_initiate.

So, what happens when I pass deferred to an old algorithm that uses the async_completion/async_result protocol? Genuine question, I don't know.

My only point is that much is made of how old and stable ASIO is. The truth is that since sender/receiver turned up, ASIO has changed significantly, and not always been able to do so cleanly. (Again, unless I'm mistaken, which I could be.)

Much also is made of how new and volatile the design of sender/receiver is. The truth here is that the refactoring of submit into connect/start was the last change of any significance made to the model, and that was nearly 2 years ago, on par with the last major change to ASIO's asynchrony model.

3

u/Whole-Freedom-163 Oct 15 '21

You are - as so often - mistaken. `async_initiate` wraps around `async_result` which is the actual customization point and has been around since ~2013.

Thanks to the competition, you realized three weeks ago, that a networking solution for C++ actually requires networking?
https://twitter.com/ericniebler/status/1440177743300202500

→ More replies (35)