Show HN: Utl:parallel – Work-stealing concurrency library for C++17

4 GeorgeHaldane 1 8/3/2025, 12:00:25 PM github.com ↗
Hello HN.

Despite the seeming triviality of the problem, there seems to be no stand-alone threadpools that support nested tasks, so I decided to make one and pair it with a proper API for parallel loops and reductions.

Recursive tasks are frequently needed in scatter/gather algorithms, a "standard" C++ solution for such parallelism would be std::async, but as practice shows it is horribly slow for small tasks (below 1ms) due to the overhead of constantly spawning/joining new threads.

To deal with this I implemented a work-stealing threadpool with some additional features sprinkled on top for convenience.

The idea itself is nothing new, but its existing implementations are usually buried somewhere deep inside the larger frameworks and it feels like a waste to bring in a huge dependency just to use what should be at best a single ~400 line class.

All this resulted in a rather nice library that I'd like to showcase here and, perhaps, hear some opinions on its improvement.

In a nutshell: - Work-stealing thread pool with a fully thread-safe API - Tasks, parallel loops and reductions - Support for recursive parallelism - Operates on containers, iterators and index ranges - Single-include, small, easy to use

https://github.com/DmitriBogdanov/UTL/blob/master/docs/modul...

Comments (1)

captaindiego · 32m ago
Thanks much, this is great!