I’m building a graphics lib, and when splitting the screen in four quadrants and drawing equation separately, I got about 3 times improvement.
But when splitting the task of drawing triangles in two, it almost decreased performance by a magnitude!
So the question is, when to use threading / async, depending on the problem size (compute time).
This is more of a generic programming problem, not unique to zig, but posting here anyway.
Also, why’s async (std.Io.Group.async) a little bit slower than threading (std.Thread)?
In addition to going through the Io vtable, the async model just requires more bookkeeping even if using the Threaded runtime which just dispatches to a thread pool.
My guess as to what’s happening is that your two tasks exhibit no concurrency, and so they are done sequentially. That then means you’re in a situation where the async overhead is only working against you.
I haven’t looked at your code but if you’re going multi threaded, but using OpenGL / Vulkan to draw your triangles there will likely be shared resources downstreme with locks around them.