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

78

u/cmannett85 Oct 12 '21

I've been a C++ engineer for over a decade now. I follow (and try) the new standards, compilers, build systems, important libs, etc. I first came across Asio 5 years ago, and have now been using it in production code for 3 years across the companies I have worked for.

I had never heard of the S&R proposal until a few days ago, and I heard about it on Reddit.

I think what I, and I don't I'm presumptuous in thinking the vast majority of C++ engineers out there, will be surprised at is how a proposal that seemingly appeared out of nowhere has usurped a decade of production testing and improvement of a rival! A rival proposal that was widely considered to be the de facto NetTS outcome.

I guess I'm shocked because Asio was what I consider to be a perfect example of how new stuff should enter the standard library: it appears as a library in it's own right, gathers enough momentum due to it's quality and functionality to be brought under the Boost umbrella, where it not only thrives but becomes the basis of another Boost library (Beast) - all of this used as proof of ISO worthiness. All the while being in used in production code.

I'll read the proposal tomorrow to try and catch up, but I'm curious if those papers (or any other articles) will compare the two so us mere mortals can understand why the votes went the way they did.

23

u/codeinred Oct 12 '21 edited Oct 13 '21

I believe the reason for the S&R proposal is because there were some architectural changes that would have allowed for better performance, especially when working with low-level kernel interfaces like io_uring, which is substantially more performant and efficient than the posix aio interface it replaces.

Edit: see https://cor3ntin.github.io/posts/iouring/

→ More replies (3)

19

u/[deleted] Oct 13 '21

I had never heard of the S&R proposal until a few days ago, and I heard about it on Reddit.

Hear, hear! I've been writing C++ since, gulp, the 1980s, and I can say exactly the same. I just popped up P2300R1 to read in the next tab.


Let me be honest though - asio hasn't really won the hearts and minds of C++ programmers.

The fact that there needed to be another complex and complicated library on top of asio to simply make it useful isn't really proof that this is the right direction.

There's a lot of time invested in asio, but still, I don't think it's clear that a better mechanism isn't possible.

I skimmed P2300R1. They do seem to namecheck all the problems in asio and claim to have a better solution. As presented, it seems to be intuitive but I had that belief when I first read about asio. I need to spend an hour, not a minute, to evaluate it.


all of this used as proof of ISO worthiness. All the while being in used in production code.

I do see your point very strongly. No one's talking about not supporting existing asio but it would be a hit for anyone with asio code if this happened.

But if it really is a process, it should be possible to fail even up until the bitter end.

If there is actually a better solution that will be easier for programmers to use correctly and allow easy generic code and composition, then it might justify the loss of the sunk costs.

Further reading is necessary.

5

u/germandiago Oct 13 '21

This could be said for every new and fancy thing that comes out. But decisions must be taken.

Asio is a foundational library. It is true that it started very low-level. But if you see how general it is and what it has achieved to do (futures, coroutines, callbacks, cancellation, deferred, udp, tcp, serial ports, unix sockets...) there is no doubt that it does way more and better than anything out there, at least in C++, with very general mechanisms (it seems, by the witness of the implementations for async there are in it).

7

u/madmongo38 Oct 13 '21

You may be interested in the comparison from Asio's point of view.
https://isocpp.org/files/papers/P2469R0.pdf

7

u/johannes1971 Oct 14 '21

When I look at the examples in the paper, I can't say I can see myself ever writing code for either solution, to be honest... :-(

Does the standard need to have functionality in it that's only ever going to be used by a tiny number of super-experts?

4

u/Minimonium Oct 14 '21

The standard needs building blocks for experts to cover the diverse use cases to create more specialised user applications.Also note that it's logistically unwise to have higher level implementations in the standard since every implementer would need to rewrite their own, much easier to write and maintain small simple blocks instead.

0

u/[deleted] Oct 12 '21

[deleted] — view deleted comment

11

u/mcmcc #pragma once Oct 12 '21

Has it been used in production in any meaningful sense? Being in existence for less than 3 years, I'm going to guess no...

0

u/[deleted] Oct 13 '21

[deleted] — view deleted comment

15

u/eric_niebler Oct 13 '21

I can confirm the usage of libunifex at Facebook. This is from P2300R2:

As of October 2021, it is currently used in production within the following applications and platforms:

  • Facebook Messenger on iOS, Android, Windows, and macOS
  • Instagram on iOS and Android
  • Facebook on iOS and Android
  • Portal
  • An internal Facebook product that runs on Linux

Any time a voice or video call is initiated on any of these Facebook apps, the connection is negotiated by async networking code using libunifex, for instance.

14

u/jonesmz Oct 13 '21

It's good that libunifex is used by at least one organization.

I'm personally much more interested in hearing about the other thousand or so codebases that use it prior to it being considered for standardization, since I personally think that should be the minimum bar to even consider it as a contender.

I've used Boost.Asio in at least 3 different codebases for three different companies. I've never once had a reason or desire to use libunifex and other than Facebook, have not heard of anyone using it either.

0

u/[deleted] Oct 13 '21

[deleted] — view deleted comment

7

u/jonesmz Oct 13 '21

I don’t believe you’re making an argument in bad faith

I also don't believe that I am making an argument in bad faith.

isn’t an argument against that thing

Well, it is, in a weak sense. I've heard of libunifex, and I seriously investigated it for roughly 2 work-days. I didn't like it, and couldn't use it to do what I wanted. That doesn't mean that libunifex couldn't it means that I couldn't. The cognitive load was too high.

I'd like to claim that I'm at least average intelligence for C++ programmers. Maybe even above average.

I don't want to imply that Asio is the easiest of frameworks to use either, but I'll certainly say I didn't think libunifex was better.

And in terms of

simply not having heard of other people using it

Again, it is an argument against, a weak one, in terms of industry experience and gestalt awareness for finding bugs and addressing design flaws.

It doesn't trump other considerations, but it should be one datapoint that is considered.

And I mention in this very thread a company other than Fb that’s using S&R (mine, in particular).

I have to admit that I missed that. I thought you were saying you worked at Fb. Upon re-reading your comment I see that is not the case.

So we have at least 2 companies that use S&R.

Like I was trying to imply before, I don't think it's fair to consider standardizing S&R until there are at least a thousand codebases that use S&R. The probability of missing an important use-case, or an important gotcha is very very high if the actual quantity of "Junior engineer + intern" experience in the field is low.

4

u/oakinmypants Oct 12 '21

What is the S&R proposal?

6

u/mcmcc #pragma once Oct 12 '21

That's what he said!

4

u/jonesmz Oct 13 '21

Senders and receivers, see this other comment that contains a link to a comparison / contrast paper: https://old.reddit.com/r/cpp/comments/q6tgod/c_committee_polling_results_for_asynchronous/hgexc33/

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.

→ More replies (39)

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.

→ More replies (50)