You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3816b80
Browse filesBrowse the repository at this point in the historyBrowse files
Add OWN_GIL subinterpreter execution to event loop pool (#44)
* Add OWN_GIL subinterpreter execution to event loop pool
This adds true parallel Python execution with OWN_GIL subinterpreters
while keeping event loop coordination in the main interpreter.
Key features:
- Session management with process affinity (same PID -> same worker)
- Sessions created automatically on first task from a process
- Sessions cleaned up via process monitoring on process exit
- Asyncio event loop per worker for coroutine support
- Tasks run via run_until_complete() in worker's event loop
- Results sent back via enif_send() to calling process
New functions:
- py_nif:owngil_create_session/1 - Create session in worker
- py_nif:owngil_submit_task/7 - Submit async task to worker
- py_nif:owngil_destroy_session/2 - Destroy session
Configuration:
{erlang_python, [{event_loop_pool_owngil, true}]}
When enabled, py_event_loop_pool:create_task/3,4 and spawn_task/3,4
automatically route through OWN_GIL workers instead of the shared
event loop.
* Add benchmark for OWN_GIL event loop pool
Compares regular event loop pool vs OWN_GIL mode:
- Sequential calls (single caller)
- Concurrent calls (multiple processes)
- CPU-bound parallel tasks (time.sleep)
Run with: escript examples/bench_owngil_pool.erl
* Fix dialyzer warnings and test failures
- Use ets:foldl instead of match spec in handle_info DOWN to avoid
dialyzer type violations with '_' atoms in record construction
- Remove unused destroy_session/2 function
- Fix test_async_coroutine_call to use asyncio.sleep instead of
custom function (OWN_GIL subinterpreters have separate namespaces)
- Fix test_same_process_same_worker to test process affinity
without relying on shared namespace state
* Fix flaky test and update documentation
- Simplify test_async_coroutine_call to use math.sqrt instead of
asyncio.sleep (more reliable on CI)
- Add OWN_GIL event loop pool documentation to event_loop_architecture.md
covering architecture, configuration, usage, and performance
0 commit comments