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:
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 theAya
thread (now calledAyaThread
).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:
15 threads, execution time ~3s
1 thread, execution time ~18s
Code for the multithreaded renderer is here: https://github.com/nick-paul/aya-raytrace/tree/thread