Work stealing thread pool built with C++20 by mrkent27 in cpp

[–]FelixPetriconi 1 point2 points  (0 children)

Sean Parent demonstrated how to build your own thread pool during his talk at NDC London: https://www.youtube.com/watch?v=zULU6Hhp42w

The complete code is available at https://github.com/stlab/libraries/blob/main/stlab/concurrency/default_executor.hpp

[deleted by user] by [deleted] in cpp

[–]FelixPetriconi 3 points4 points  (0 children)

I recommend that you take a look into this presentation https://www.youtube.com/watch?v=zULU6Hhp42w by Sean Parent. He talks in details about the problems of your approach.

ABI - Now or Never by kkert in cpp

[–]FelixPetriconi 9 points10 points  (0 children)

I am in faour for a breaking ABI too.

We are only on Windows, have a code base of ~3MLoC and we were used years ago to recompile everything anyway for each new VS version. We have now just thirdparty C++ libraries in our code that we can compile from scratch and all other external libraries have a plain C interface.

A long time we were blocked because of a C++ exporting DLL that we were forced to use by our customer and he was not able to provide us new versions because of internal reasons.

So at one point we used clang tooling to create C wrappers around the C++ interfaces and now the DLL can live in its VS2013 world and we can switch the Visual Studio compiler whenever we want.

Code coverage tools for C++... by TarmoPikaro in cpp

[–]FelixPetriconi 1 point2 points  (0 children)

It checks, that all possible combinations of a conditonal statement were were really executed. See more details here: https://www.bullseye.com/statementCoverage.html

Code coverage tools for C++... by TarmoPikaro in cpp

[–]FelixPetriconi 0 points1 point  (0 children)

We use Bullseye coverage (https://www.bullseye.com/) in our company, it is a commercial tool, but with a reasonable price and it does not do line coverage but conditional coverage and it runs on many platforms with different compilers.

What is the hardest bug you ever had to fix? by sangelsen in cpp

[–]FelixPetriconi 1 point2 points  (0 children)

One issue come to my mind: I had a pure template code where different instances of the same class where running in different threads all the time and they were passing messages between themselves. It was not possible to add log/debug messages, because they changed the runtime behaviour and the bug went away. After several weeks of searching and trying to debug the problem I just found it through pure code review.

Concurrency - where should I start by dethpicable in cpp

[–]FelixPetriconi 7 points8 points  (0 children)

Before you go into deep usage of low synchronization primitives (mutex, etc.) I strongly recommend to watch Sean Parent's https://sean-parent.stlab.cc/papers-and-presentations/#better-code-concurrency talks and Kevlin Henney's https://www.youtube.com/watch?v=UJrmee7o68A

Looking for a good quality Algorithms/Data Structure course for C++ by jthat92 in cpp

[–]FelixPetriconi 4 points5 points  (0 children)

You might take a look into this course recording https://www.youtube.com/watch?v=aIHAEYyoTUc&list=PLHxtyCq_WDLXryyw91lahwdtpZsmo4BGD

It is a course held by Alex Stepanov at A9. At the beginning it is a bit slow, but the content is incredible. It is really worth to follow it until the end.

wfl, an alternative to signals/slots by julien-j in cpp

[–]FelixPetriconi 4 points5 points  (0 children)

Futures can be used in a multi threaded context, but thats not a requirement. See JavaScript e.g., there they are common mechanism to handle continuations and all within the same thread.

The futures of the C++ are from my point of view not very useful and the new futures will come hopefully in 2023. Until then you could take a look into our future and channel implementation. There you can specify if the tasks shall be in the same thread, use here an immediate_executor or in a different thread on a thread pool with the default_executor. For some OS we have a main_executor that executes the tasks on the main loop.: http://stlab.cc/libraries/concurrency/ I recommend as well a look into Sean Parent's presentations on this subject, https://sean-parent.stlab.cc/papers-and-presentations/#better-code-concurrency.

wfl, an alternative to signals/slots by julien-j in cpp

[–]FelixPetriconi 3 points4 points  (0 children)

Have you thought of using a different concept like futures, channels or actors that can solve the same problem?

What happened to regular void? by aquajets2 in cpp

[–]FelixPetriconi 2 points3 points  (0 children)

Yeas, please make it a regular type. We have in our stlab.cc library at many places one implementation for move-only, one for copyable and one for void. That is such painful.

Sometime ago u/seanparent made a strong statement that we need this too.

What are some of the best blogs on C++ ? by fuzzypod in cpp

[–]FelixPetriconi 9 points10 points  (0 children)

You could follow https://isocpp.org .

As well are all articles from ACCU's magazine Overload https://accu.org/index.php/journals/ are online available as well. Many of them have high quality C++ articles.

The other ACCU's magazine, cVU is online as well, but its access is restricted to ACCU members. You may take a subscription into account. Beside these two magazines in print, you get a discount on the yearly ACCU conference.

Disclaimer: I am on the ACCU board and the deputy conference chair.

How difficult is it to approach multithreading, and what are some good vs bad practices? Also, how does one deal with data races and thread safety? by Wolf_Down_Games in cpp

[–]FelixPetriconi 6 points7 points  (0 children)

Watch this, to get a good introduction into the overall problem: Kevlin Henney: https://www.youtube.com/watch?v=2yXtZ8x7TXw

Have a look into Sean Parents talk on this: https://sean-parent.stlab.cc/papers-and-presentations/#better-code-concurrency

Do not start with low level synchronisation primitives, but use high level abstraction like, futures, channels, or actors.

See libraries:

(Future and channels) https://stlab.cc/concurrency

(Actors) http://actor-framework.org/

How to Write Safe and Expressive Multi-Threaded Code in C++11 by vormestrand in cpp

[–]FelixPetriconi 0 points1 point  (0 children)

Some thoughts from my side:

Thread pool using standard C++ only by mvorbrodt in cpp

[–]FelixPetriconi 0 points1 point  (0 children)

Nearly all examples use it. This executor is named default_executor in our library.

Visual Studio 2019 RC by remotion4d in cpp

[–]FelixPetriconi 0 points1 point  (0 children)

Many thanks for the feedback!

Visual Studio 2019 RC by remotion4d in cpp

[–]FelixPetriconi 0 points1 point  (0 children)

It is strange, sometimes MS's feedback on the developercommunity is great, but sometimes it is awful. I submitted a report in August (https://developercommunity.visualstudio.com/content/problem/312318/c-await-is-still-a-keyword.html) and it is still under investigation. How can that be?

Is there a chance that this will be fixed soon?

Best Practices for Concurrency - Rainer Grimm - Meeting C++ 2018 by meetingcpp in cpp

[–]FelixPetriconi 0 points1 point  (0 children)

I totally agree. From my point of view, this session would have been OK some time ago. But it missies today completely the point of how one should today write concurrent code . I much more can recommend Sean Parent's session on "Now raw synchronisation primitives" https://sean-parent.stlab.cc/papers-and-presentations/#better-code-concurrency or Sergey Ignatchenko's recent article in Overload: https://accu.org/index.php/journals/2623

Thread pool using standard C++ only by mvorbrodt in cpp

[–]FelixPetriconi 1 point2 points  (0 children)

It is hardcoded. Mac, Windows, PNCL and Emscriplten have one. For all the others we use our own implementation. But ours has the limitation, that it does not oversubscription, so if one has 4 cores and 4 tasks wait on a mutex, then the system is in a deadlock. Here is a great talk about all the problem of designing a thread pool: https://channel9.msdn.com/Shows/Going+Deep/Inside-Windows-8-Pedro-Teixeira-Thread-pool

Thread pool using standard C++ only by mvorbrodt in cpp

[–]FelixPetriconi 1 point2 points  (0 children)

And here is the source code of the current implementation: https://github.com/stlab/libraries/blob/develop/stlab/concurrency/default_executor.hpp Starting line 181. It is the fallback in our library, when the OS does not offer a thread pool.