Summary
Python versions less than 3.14t have GIL in place which ensures that only one thread can execute at a time on one core and Python doesn't use all the cores out of the box. Now, if the SyncMapServer code, we use ThreadPool Executor to trigger the map's handler concurrently which turn very easily leads to CPU thrashing depending on the end user's actual UDF core logic (whether it's pure I/O or CPU)
Asyncio helps Python execute I/O-bound workloads concurrently, but does not help work around the Python GIL and provide CPU parallelism.
What change needs making?
Use Cases
When would you use this?
- CPU Bound use-cases would benefit from this as people might NOT realize what's happening and assume that they're processing things concurrently when it's sequential in reality (Not saying it's hard to spot, it's just they need to realize it sooner than later)
Message from the maintainers:
If you wish to see this enhancement implemented please add a 👍 reaction to this issue! We often sort issues this way to know what to prioritize.
Summary
Python versions less than 3.14t have GIL in place which ensures that only one thread can execute at a time on one core and Python doesn't use all the cores out of the box. Now, if the
SyncMapServercode, we useThreadPool Executorto trigger the map's handler concurrently which turn very easily leads to CPU thrashing depending on the end user's actual UDF core logic (whether it's pure I/O or CPU)Asyncio helps Python execute I/O-bound workloads concurrently, but does not help work around the Python GIL and provide CPU parallelism.
What change needs making?
We can likely revisit and decide if we want to control a singleTon like ProcessPoolExecutor as well to give end users the capacity to choose
Code Reference:
numaflow-python/packages/pynumaflow/pynumaflow/mapper/_servicer/_sync_servicer.py
Lines 44 to 80 in 5fd1823
Use Cases
When would you use this?
Message from the maintainers:
If you wish to see this enhancement implemented please add a 👍 reaction to this issue! We often sort issues this way to know what to prioritize.