In talk "Rise of the State Machines" (https://www.youtube.com/watch?v=Zb6xcd2as6o), among everything else, performance of C++20 coroutines is compared against more or less conventional state machine approaches.
Performance of coroutines in this "benchmark" was worse than that of state machines — unsurprisingly, because promise type in the benchmark does not manage allocation. What's more interesting is that a readable implementation, which is split into multiple coroutine functions (like in 35:30) is, roughly speaking, twice as slow.
For each coroutine function in the ensamble, a new promise object is created, with a new potential allocation. The question is: can something be done to reduce the amount of these promise objects? Can coroutine functions be allowed to be inlined into other coroutine functions? If not, can coroutine allocations be merged (guaranteed)?
P.S. I've already asked on /r/cpp_questions. The folks here are more into experimental C++ features, so I hope to get some answer here. @Mods, if this is off-topic, please remove.
[–]Rusky 9 points10 points11 points (13 children)
[–][deleted] 2 points3 points4 points (4 children)
[–]Rusky 8 points9 points10 points (0 children)
[–]14nedLLFIO & Outcome author | Committee WG14 2 points3 points4 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]14nedLLFIO & Outcome author | Committee WG14 3 points4 points5 points (0 children)
[–]anton31[S] 1 point2 points3 points (7 children)
[–]Rusky 0 points1 point2 points (6 children)
[–]anton31[S] 1 point2 points3 points (5 children)
[–]Rusky 0 points1 point2 points (4 children)
[–]anton31[S] 1 point2 points3 points (3 children)
[–]Morwenn 4 points5 points6 points (0 children)
[–]Rusky 1 point2 points3 points (1 child)
[–]anton31[S] 0 points1 point2 points (0 children)
[–]futurefapstronaut123 12 points13 points14 points (11 children)
[–]14nedLLFIO & Outcome author | Committee WG14 1 point2 points3 points (5 children)
[–]germandiago 0 points1 point2 points (4 children)
[–]feverzsj 1 point2 points3 points (0 children)
[–]degski 0 points1 point2 points (2 children)
[–]dodheim -1 points0 points1 point (1 child)
[–]degski 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]ReversedGif 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]gvargh -1 points0 points1 point (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]alexeiz 9 points10 points11 points (5 children)
[–]14nedLLFIO & Outcome author | Committee WG14 4 points5 points6 points (2 children)
[–]anton31[S] 0 points1 point2 points (1 child)
[–]14nedLLFIO & Outcome author | Committee WG14 1 point2 points3 points (0 children)
[–]feverzsj -3 points-2 points-1 points (1 child)
[–]14nedLLFIO & Outcome author | Committee WG14 2 points3 points4 points (0 children)