WSGISwitchInterval in mod_wsgi 6.0.0 - Graham Dumpleton
Briefly

WSGISwitchInterval in mod_wsgi 6.0.0 - Graham Dumpleton
WSGISwitchInterval provides a Python tuning knob that affects how often the interpreter scheduler nudges the current thread to release and reacquire the GIL. The GIL serializes bytecode execution across threads, so other threads can run only when the lock holder releases it. Releases can be voluntary during I/O, but CPU-busy threads still need periodic handoffs. Earlier CPython versions used a bytecode-count trigger, which produced inconsistent wall-clock intervals because bytecodes vary in cost. Python 3.2 introduced a time-based scheduler that makes handoffs depend on elapsed time rather than bytecode counts. The directive’s value is tied to measuring real workload behavior and using telemetry to choose effective tuning settings.
"The Python GIL is the lock that serialises bytecode execution across threads in a CPython process. Only one thread at a time holds it. For other threads to make progress on Python code, the holder has to release the lock. Some releases are voluntary, for instance during I/O calls that drop the GIL while they wait. Voluntary releases are not enough on their own to schedule cleanly between several CPU-busy threads though, so the interpreter also has a scheduler that nudges the holder to give the lock up periodically. That scheduler is what the switch interval controls."
"In CPython 2 the scheduler was bytecode-count based. After every N bytecodes the interpreter would check for pending signals, drop the lock, and reacquire it. The setting was sys.setcheckinterval(N), default 100 ticks. The problem with bytecode counting was that bytecodes are not equal-cost. Some operations completed in a fraction of a microsecond. Others, like calling out into a slow built-in, took milliseconds. So the actual wall-clock interval between handoffs varied widely depending on what code was running."
"Python 3.2 replaced this with a time-based scheduler. Antoine Pitrou's new GIL implementation moved the handoff trigg"
Read at Grahamdumpleton
Unable to calculate read time
[
|
]