aya icon indicating copy to clipboard operation
aya copied to clipboard

WIP: Multithreading

Open nick-paul opened this issue 1 year ago • 0 comments

I removed all references to the global Aya thread and passed execution context down using the refactored blocks from this PR. With a bit more refactoring I was able to provide an API to spawn and manage multiple instances the Aya thread (now called AyaThread).

The API is very clunky and there are a handful of bugs I still need to work through but the implementation is quite stable now.

Examples

I used the raytracer implementation to test stability and performance since it was a fairly large aya project. I implemented a thread pool using the current version of the thread API. It is a bit clunky and needs some improvement but was very stable overall.

The performance is significantly better with more threads but there is still quite a bit of overhead. Rendering an image with 15 threads gave a ~6x speedup as seen below:

multithread_3s
15 threads, execution time ~3s

singlethread_18s 1 thread, execution time ~18s

Code for the multithreaded renderer is here: https://github.com/nick-paul/aya-raytrace/tree/thread

nick-paul avatar Mar 27 '24 21:03 nick-paul