Improve executor pool configuration and fix idle GIL contention#16
Merged
Improve executor pool configuration and fix idle GIL contention#16
Conversation
- Add MIN_EXECUTORS (2) and increase MAX_EXECUTORS to 32 - Set default executors to 4 (benchmarked sweet spot) - Fix GIL contention: acquire GIL only when processing actual work, not while idle waiting for requests. This prevents idle executor threads from competing with dirty schedulers running Python work via the context-based API. Benchmark results (14 dirty CPU schedulers): - 4 executors: best sync (400k/sec) and concurrent performance - Context API: stable regardless of executor count (GIL fix verified)
2841013 to
6d72b2e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
(dirty_cpu_schedulers div 2) + 1Root Cause
Idle executor threads were continuously cycling through GIL acquire/release, competing with dirty schedulers running actual Python work via the context-based API (
py:call()).Fix
Changed
multi_executor_thread_main()to: