This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2020年03月19日 00:57 by vstinner, last changed 2022年04月11日 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 19067 | merged | vstinner, 2020年03月19日 01:31 | |
| PR 19077 | merged | vstinner, 2020年03月19日 17:38 | |
| PR 19080 | merged | vstinner, 2020年03月19日 18:28 | |
| PR 19087 | merged | vstinner, 2020年03月20日 08:38 | |
| PR 19091 | merged | vstinner, 2020年03月20日 13:13 | |
| Messages (8) | |||
|---|---|---|---|
| msg364580 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2020年03月19日 00:57 | |
When a thread gets a signal, SIGNAL_PENDING_SIGNALS() sets signals_pending to 1 and eval_breaker to 1. In this case, _PyEval_EvalFrameDefault() calls handle_signals(), but since it's not the main thread, it does nothing and signals_pending value remains 1. Moreover, eval_breaker value remains 1 which means that the following code will be called before executing *each* bytecode instruction.
if (_Py_atomic_load_relaxed(eval_breaker)) {
(...)
opcode = _Py_OPCODE(*next_instr);
if (opcode == SETUP_FINALLY || ...) {
...
}
if (_Py_atomic_load_relaxed(&ceval->signals_pending)) {
if (handle_signals(tstate) != 0) {
goto error;
}
}
if (_Py_atomic_load_relaxed(&ceval->pending.calls_to_do)) {
...
}
if (_Py_atomic_load_relaxed(&ceval->gil_drop_request)) {
...
}
if (tstate->async_exc != NULL) {
...
}
}
This is inefficient.
I'm working on a PR modifying SIGNAL_PENDING_SIGNALS() to not set eval_breaker to 1 if the current thread is not the main thread.
|
|||
| msg364583 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2020年03月19日 01:35 | |
I found this issue while working on PR 19066 of bpo-39984. |
|||
| msg364611 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2020年03月19日 16:40 | |
New changeset 5a3a71dddbe80edc75a3a74ce3b7978cf8635901 by Victor Stinner in branch 'master': bpo-40010: Optimize signal handling in multithreaded applications (GH-19067) https://github.com/python/cpython/commit/5a3a71dddbe80edc75a3a74ce3b7978cf8635901 |
|||
| msg364628 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2020年03月19日 18:48 | |
New changeset a36adfa6bbf5e612a4d4639124502135690899b8 by Victor Stinner in branch 'master': bpo-39877: 4th take_gil() fix for daemon threads (GH-19080) https://github.com/python/cpython/commit/a36adfa6bbf5e612a4d4639124502135690899b8 |
|||
| msg364659 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2020年03月20日 08:29 | |
New changeset da2914db4b6f786a1e9f0b424efeeb6ca9418912 by Victor Stinner in branch 'master': bpo-40010: Pass tstate to ceval GIL functions (GH-19077) https://github.com/python/cpython/commit/da2914db4b6f786a1e9f0b424efeeb6ca9418912 |
|||
| msg364666 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2020年03月20日 12:39 | |
New changeset d2a8e5b42c5e9c4e745a0589043a8aebb49f8ca2 by Victor Stinner in branch 'master': bpo-40010: COMPUTE_EVAL_BREAKER() checks for subinterpreter (GH-19087) https://github.com/python/cpython/commit/d2a8e5b42c5e9c4e745a0589043a8aebb49f8ca2 |
|||
| msg364667 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2020年03月20日 13:50 | |
New changeset d83168854e19d0381fa57db25fca6c622917624f by Victor Stinner in branch 'master': bpo-40010: Optimize pending calls in multithreaded applications (GH-19091) https://github.com/python/cpython/commit/d83168854e19d0381fa57db25fca6c622917624f |
|||
| msg368171 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2020年05月05日 15:27 | |
Good catch on this, Victor. Thanks for doing it. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:59:28 | admin | set | github: 84191 |
| 2020年05月05日 15:27:40 | eric.snow | set | nosy:
+ eric.snow messages: + msg368171 |
| 2020年03月25日 17:33:17 | vstinner | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2020年03月20日 14:18:47 | vstinner | set | title: Inefficient sigal handling in multithreaded applications -> Inefficient signal handling in multithreaded applications |
| 2020年03月20日 13:50:38 | vstinner | set | messages: + msg364667 |
| 2020年03月20日 13:13:01 | vstinner | set | pull_requests: + pull_request18451 |
| 2020年03月20日 12:39:06 | vstinner | set | messages: + msg364666 |
| 2020年03月20日 08:38:42 | vstinner | set | pull_requests: + pull_request18447 |
| 2020年03月20日 08:29:20 | vstinner | set | messages: + msg364659 |
| 2020年03月19日 18:48:34 | vstinner | set | messages: + msg364628 |
| 2020年03月19日 18:28:08 | vstinner | set | pull_requests: + pull_request18438 |
| 2020年03月19日 17:38:09 | vstinner | set | stage: patch review pull_requests: + pull_request18433 |
| 2020年03月19日 16:40:16 | vstinner | set | messages: + msg364611 |
| 2020年03月19日 01:35:28 | vstinner | set | messages:
+ msg364583 stage: patch review -> (no value) |
| 2020年03月19日 01:31:35 | vstinner | set | keywords:
+ patch stage: patch review pull_requests: + pull_request18421 |
| 2020年03月19日 00:57:25 | vstinner | set | type: performance |
| 2020年03月19日 00:57:19 | vstinner | create | |