Re:C++20: Building a Thread-Pool with Coroutines
by sannysanoff on Monday May 24, 2021 @03:35AM
(#27261874)
I have an internal scheduler which prevents spawning too many of them. In any case, it's only stack & context allocation (and freeing) which is not that CPU expensive at my rate (does not show in profiler too much). Also, multiple concurrent processes in worst cases use much virt memory, because of stack allocations, not much resident memory in fact.
> once compiler support has improved enough
I give it min 5 years. It's already few year since it was in clang. I don't believe it will be fixed soon in gdb/lldb. You need to introduce many non-generic things: at least new stack chaining debug information for proper call-stacks, which is (and will!) be threadpool-implementation specific, because otherwise it should be part of standard, part of compiler implementation which is even worse. With local vars it's slightly easier however.
Re:C++20: Building a Thread-Pool with Coroutines
by sannysanoff on Monday May 24, 2021 @03:36AM
(#27261885)
it does not look like it's using boost::context. At least I never saw it in runtime. It's using its own asm routines for save/restore the context.
Re:C++20: Building a Thread-Pool with Coroutines
by MichaEiler on Monday May 24, 2021 @06:01AM
(#27262633)
As far as I can tell the developer is using Fibers on Windows and boost::context on all other operating systems. You can see that he has a forward declaration in "libgo/context/fcontext.h" and then links against the respective boost assembly files in the CMakeLists.txt.
Re:C++20: Building a Thread-Pool with Coroutines
by sannysanoff on Wednesday May 26, 2021 @07:23AM
(#27289047)
Ah, correct. He's using asm files for fcontext from boost.context. Looks like those are copied into his tree from boost during build phase, and those files were the only I found. Thanks for pointing out. I maybe will need to test it on ARM one day, now I have peace of mind regarding ARM.
Regarding your debugging issues. I'd be surprised if this doesn't improve over the next year or two. Clang afaik isn't even fully compatible with the final version of coroutines yet. Microsoft has done a lot of work on the compiler itself. I'd assume that Visual Studio will likely ship improvements once they release VS2022(?). Of course these are only guesses from my side.
Summing it up it sounds to me like you suffered from the curse of being an early adopter. It would be interesting to see if you'd have less issues once tooling and compiler support has improved enough.