cubed-dev / cubed

Bounded-memory serverless distributed N-dimensional array processing
https://cubed-dev.github.io/cubed/
Apache License 2.0
121 stars 14 forks source link

Manually manage the GIL with Cython #497

Open alxmrs opened 3 months ago

alxmrs commented 3 months ago

I suspect that the performance of the ThreadPoolExecutor would substantially increase if we strategically placed cython with nogil calls.

There are drawbacks to process based parallelism; namely, there is a high overhead and IPC latency compared to multithreading.

alxmrs commented 3 months ago

Memory views for shared memory: https://docs.cython.org/en/latest/src/userguide/memoryviews.html

tomwhite commented 3 months ago

Another approach is free-threaded Python, which is just ramping up (but is going to take some time):

alxmrs commented 3 months ago

TIL! I didn’t realize threaded Python was coming so soon! Thanks for the pointers.

The Cython tricks may be useful in the near-term for younger versions of Python.