mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-135953: Add GIL contention markers to sampling profiler Gecko format (#139485)
This commit enhances the Gecko format reporter in the sampling profiler to include markers for GIL acquisition events.
This commit is contained in:
parent
994ab5c922
commit
89a914c58d
9 changed files with 627 additions and 82 deletions
|
|
@ -207,6 +207,7 @@ drop_gil_impl(PyThreadState *tstate, struct _gil_runtime_state *gil)
|
|||
_Py_atomic_store_int_relaxed(&gil->locked, 0);
|
||||
if (tstate != NULL) {
|
||||
tstate->holds_gil = 0;
|
||||
tstate->gil_requested = 0;
|
||||
}
|
||||
COND_SIGNAL(gil->cond);
|
||||
MUTEX_UNLOCK(gil->mutex);
|
||||
|
|
@ -320,6 +321,8 @@ take_gil(PyThreadState *tstate)
|
|||
|
||||
MUTEX_LOCK(gil->mutex);
|
||||
|
||||
tstate->gil_requested = 1;
|
||||
|
||||
int drop_requested = 0;
|
||||
while (_Py_atomic_load_int_relaxed(&gil->locked)) {
|
||||
unsigned long saved_switchnum = gil->switch_number;
|
||||
|
|
@ -407,6 +410,7 @@ take_gil(PyThreadState *tstate)
|
|||
}
|
||||
assert(_PyThreadState_CheckConsistency(tstate));
|
||||
|
||||
tstate->gil_requested = 0;
|
||||
tstate->holds_gil = 1;
|
||||
_Py_unset_eval_breaker_bit(tstate, _PY_GIL_DROP_REQUEST_BIT);
|
||||
update_eval_breaker_for_thread(interp, tstate);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue