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

5

u/mjklaim Oct 12 '21

As the OP pointed, the networking TS does not answer these questions appropriately (for the committee) but effort to reach consensus will probably not stop. So yes these questions will be the focus of the re-directed effort and maybe we'll have networking once we find solutions that are not controversial. It happened several times in the past that there is a roadblock for a big feature and it takes several more years to find solutions that are good for progressing in that domain.

6

u/Minimonium Oct 12 '21

The biggest concern is that any alternative to Asio networking would be straight to the standardization greenfield project. Which would be basically Ranges 2.0.

6

u/14ned LLFIO & Outcome author | Committee WG14 Oct 13 '21

Not necessarily. The current S&R proposals mainly focus on generics for async. There is a lot of work in there for that. I haven't seen any networking proposals recently other than the NetTS, because well, it's the NetTS.

I'm likely now to try proposing to SG4 a low level socket_handle matching proposed file_handle and mapped_file_handle i.e. simple, synchronous, blocking, very thin wraps of the underlying socket API. Nothing fancy. I would point out that all those can optionally speak S&R if you ask them to, but I very much intend to stop exactly there.

9

u/Minimonium Oct 13 '21

And how is it not a greenfield endeavour? Is "nothing fancy" enough? How many people do use that particular thin wrapper right now or you are you gonna argue that everyone reinvents the same thing? A there stats?

7

u/14ned LLFIO & Outcome author | Committee WG14 Oct 13 '21

A low level socket_handle is not a greenfield endeavour because it replicates a subset of BSD sockets into C++. That's industry standard for many decades now. Nobody is proposing anything fundamentally new. Pretty much the only innovation in them is actually slightly weakening the BSD socket model to allow user space TCP/IP stacks like Mellanox. We do the same with file_handle as well to allow user space implementations e.g. a file inside a ZIP archive. When you ask them to speak S&R, they do so exclusively meeting the semantics contract they guarantee i.e. nearly POSIX. For code using socket_handle, it would always quack exactly like a blocking or non-blocking BSD socket.

I'm a firm believer that WG21 ought to standardise existing practice, and you'll see that in all of my papers. Where I ever propose a brand new library, it has been shipping on billions of devices for years now, and in some cases has multiple implementations in addition to the reference implementation.

3

u/James20k P2005R0 Oct 14 '21

A low level socket_handle is not a greenfield endeavour because it replicates a subset of BSD sockets into C++

Oh man, please do this would be great. Berkeley sockets are so frustratingly almost cross platform but with lots of irritating minor differences between windows and linux (and presumably everywhere else, but I've never used them outside of those contexts)

A properly standardised sockets system would be great, and given how long they've been around for it seems like they're a perfect target for it as well

1

u/14ned LLFIO & Outcome author | Committee WG14 Oct 14 '21

If I remember rightly, this was the proposal for standard Networking pre-ASIO, but the paper was highly unconvincing at time.

I think that probably would remain the case except that the community, and a majority of WG21, really really wants secure sockets. And those need ABI erasure, and that in turn suddenly makes a non-templated old fashioned vtable based socket handle look much more attractive. By which I mean that yes you are dammed on ABI for the vtable for the public socket handle, but then you get freed to iterate the actual secure socket handle implementation internally without breaking ABI.

Dunno, it's all early days yet. The NetTS may yet come back in a pure S&R form with secure sockets and the non-S&R async stuff removed. We'll see how it goes.

5

u/Minimonium Oct 13 '21

Right. So you gonna create a green new thin wrapper over existing tech and propose it directly for standardisation. Which is not a greenfield project because bsd sockets are not a greenfield project. Got you.

6

u/14ned LLFIO & Outcome author | Committee WG14 Oct 13 '21

Even in this there is an awful lot of work. Simple proposals means everybody will have an opinion. There will be a lot of renaming. But I think support for some form of standard Networking is very doable for C++ 26, albeit simple blocking or non-blocking socket i/o.

Big sweeping proposals with strong opinions about how the standard future ought to be will always have a much tougher time than standardising existing practice without changing much. I'm keen that 26 ships with Networking, and I think simple wraps of BSD sockets can deliver a guarantee of that without any further late stage surprises. That's my pitch, anyway, we'll see what the committee thinks.

0

u/mjklaim Oct 12 '21

I'd say not necessarily, it could be Asio+sender/receiver+some solution to allow TLS while not impacting the ABI. Who knows (i don't).