Live data from Hacker News

FoundationDB's Flow – Bringing Actor-Based Concurrency to C++11

apple.github.io

31–38 of 38 posts

Re: FoundationDB's Flow – Bringing Actor-Based Concurrency to C++11

#31

Earlier quoted context omitted.

> Nah, coroutines/async/etc often lives in various threads (ie, the workers can schedule one of them on different threads during the lifetime and they live concurrently), so you still have all the issues of threading (+ new ones since things like thread-local variables aren't reliable if an async/coroutines moves threads between calls). In cooperative scheduling how is it possible to have two coroutines running concu…

You're thinking of older early coroutines or in singlethreaded runtimes (JS). It's M:N threading, most logical threads/tasks are more lightweight than full OS threads, the logical ones should preferably behave cooperatively but they can be scheduled onto any number of real worker threads (usually these systems picks something like 2x worker threads compared to real CPU/Core count to manage some codepaths not being as…

C++20 co-routines model is based on .NET ones, as the original model was proposed by Microsoft and inspired on WinRT work.

If you know how to create asyncable types on .NET, the magic methods expected by C++ compiler will feel familiar.

Re: FoundationDB's Flow – Bringing Actor-Based Concurrency to C++11

#32
post #29

Earlier quoted context omitted.

not really, they yield to other event sources, which is the opposite of waiting (which blocks forward progress and is a violation of real-time guarantees)

The actor itself can be said to be waiting. When it yields, the thread is then able to run another actor which was waiting on a message, and which then has a message on the queue.

That sounds like a misunderstanding of how the actor model works. An actor doesn't wait. It's an event-driven system, it doesn't get to own and decide when messages get fed to it.

Re: FoundationDB's Flow – Bringing Actor-Based Concurrency to C++11

#33
post #29

Earlier quoted context omitted.

The actor itself can be said to be waiting. When it yields, the thread is then able to run another actor which was waiting on a message, and which then has a message on the queue.

That sounds like a misunderstanding of how the actor model works. An actor doesn't wait. It's an event-driven system, it doesn't get to own and decide when messages get fed to it.

Are there any actor system implementations that you know of that work differently?

Re: FoundationDB's Flow – Bringing Actor-Based Concurrency to C++11

#34
post #33

Earlier quoted context omitted.

That sounds like a misunderstanding of how the actor model works. An actor doesn't wait. It's an event-driven system, it doesn't get to own and decide when messages get fed to it.

Are there any actor system implementations that you know of that work differently?

Well in mine for example, threads are pinned to a core and always spin, and actors are pinned to a given thread (you can have an arbitrary number of actors per thread, they're just objects), so "waiting" is certainly not something you'd use to describe the setup in any capacity.

Re: FoundationDB's Flow – Bringing Actor-Based Concurrency to C++11

#35
post #33

Earlier quoted context omitted.

Are there any actor system implementations that you know of that work differently?

Well in mine for example, threads are pinned to a core and always spin, and actors are pinned to a given thread (you can have an arbitrary number of actors per thread, they're just objects), so "waiting" is certainly not something you'd use to describe the setup in any capacity.

What happens when there are no messages on the queue for a given actor?

Re: FoundationDB's Flow – Bringing Actor-Based Concurrency to C++11

#36
post #35

Earlier quoted context omitted.

Well in mine for example, threads are pinned to a core and always spin, and actors are pinned to a given thread (you can have an arbitrary number of actors per thread, they're just objects), so "waiting" is certainly not something you'd use to describe the setup in any capacity.

What happens when there are no messages on the queue for a given actor?

An actor does not have a queue; that's again the whole point I already made: it's event-driven, things are decoupled and the actor is not aware of how control flow happens.

Regardless, when the queue which exists and is per-thread is empty, the program terminates.

Re: FoundationDB's Flow – Bringing Actor-Based Concurrency to C++11

#37
post #31

Earlier quoted context omitted.

You're thinking of older early coroutines or in singlethreaded runtimes (JS). It's M:N threading, most logical threads/tasks are more lightweight than full OS threads, the logical ones should preferably behave cooperatively but they can be scheduled onto any number of real worker threads (usually these systems picks something like 2x worker threads compared to real CPU/Core count to manage some codepaths not being as…

C++20 co-routines model is based on .NET ones, as the original model was proposed by Microsoft and inspired on WinRT work. If you know how to create asyncable types on .NET, the magic methods expected by C++ compiler will feel familiar.

You mean in the sense that async methods return "awaitable" (Value)Task objects that contains the actual activation machinery that can be queried for liveness status?

It's funny that they're actually revamping the entire machinery for .NET 11 to defer allocations by default for non-waiting codepaths (Not sure, but iirc that machinery might require JIT compilation so would've perhaps not been possible to use for C++).

Re: FoundationDB's Flow – Bringing Actor-Based Concurrency to C++11

#38
post #26

Earlier quoted context omitted.

Coroutines aren't great, even C++26 is explicitly avoiding them for its foundational concurrency model. In any case a good concurrency library doesn't need more than C++14.

Is it? Senders/receivers is based on NVidias experience using them on CUDA. Naturally I haven't followed them that much, given how far away C++26 is from being usable for portable code. Compilers are finally getting good enough with C++20 support for updating the default version.

There is no shared lineage here. Some of the people who worked on sender/receivers indeed also worked at Nvidia on Thrust, which never had anything to do with coroutines.
Post reply on HN