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 2017年07月05日 20:30 by eric.snow, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 2594 | merged | eric.snow, 2017年07月05日 21:10 | |
| PR 3379 | merged | eric.snow, 2017年09月06日 04:14 | |
| PR 3397 | merged | eric.snow, 2017年09月06日 22:31 | |
| PR 3458 | merged | eric.snow, 2017年09月08日 17:37 | |
| PR 3498 | merged | vstinner, 2017年09月11日 15:04 | |
| PR 3499 | merged | vstinner, 2017年09月11日 15:09 | |
| PR 3506 | merged | eric.snow, 2017年09月11日 22:54 | |
| PR 3507 | merged | eric.snow, 2017年09月11日 23:08 | |
| PR 3567 | merged | eric.snow, 2017年09月14日 07:15 | |
| PR 4532 | merged | vstinner, 2017年11月23日 23:11 | |
| Messages (20) | |||
|---|---|---|---|
| msg297780 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2017年07月05日 20:30 | |
CPython's C code makes extensive use of global variables. The globals fall into one of several categories: * (effectively) constants (incl. static types) * freelists, caches, and counters * used exclusively in main or in REPL * process-global state * module state * Python runtime state Those in the last category are not explicitly organized nor easily discoverable. Among other things, this has an impact on efforts that change the runtime (e.g. my multi-core Python project). To improve the situation I'd like to do the following: 1. group the (stateful) runtime globals into various topical structs 2. consolidate the topical structs under a single top-level _PyRuntimeState struct 3. add a check-c-globals.py script that helps identify runtime globals One side effect of consolidating these globals is a significant performance improvement of CPython. Presumably this is due to the caching behavior of a single struct vs. that of dozens of separate globals. I have a patch and will put up a PR momentarily. |
|||
| msg297782 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2017年07月05日 21:12 | |
One thing I'd like to also try is to use a freelist embedded in _PyRuntimeState for the PyInterpreterState and PyThreadState linked lists. |
|||
| msg297794 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2017年07月06日 03:42 | |
See also issue29881. |
|||
| msg297848 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2017年07月06日 22:08 | |
After looking at the PR, I'm a bit skeptical about this. Suddenly a lot of things which are implementation details get moved to the public include files, which makes things more confusing from my POV. I also don't know why all globals should be consolidated in a single place (it is not a widespread policy in other projects AFAIK, but I may be mistaken). Perhaps it would be more reasonable to consolidate the globals in each .c file independently, without trying to join all of them together in one place nor expose them in the public include files. |
|||
| msg297851 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2017年07月07日 01:59 | |
The core motivation driving the original refactoring was to better understand and consolidate our runtime state in order to clarify what the GIL is actually protecting (aside from the reference counts). That then turned out to have surprising performance benefits (presumably by way of loading all of this state permanently into the CPU cache and then keeping it there). The changes to the public include files arise more from the fact we don't currently have a common place to put internal CPython headers for declarations we want to share across compilation modules. I agree the latter is confusing, and it could be worth having a separate "Include/internal/CPython.h" header that outright failed the build if you attempted to include it without Py_BUILD_CORE set. (This also ties into my comments on the PR, where I believe the current approach of mixing public and private state in the same structs will cause problems with compilers generating incorrect field offsets in extension modules and embedding applications) |
|||
| msg301428 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2017年09月06日 01:26 | |
New changeset 76d5abc8684bac4f2fc7cccfe2cd940923357351 by Eric Snow in branch 'master': bpo-30860: Consolidate stateful runtime globals. (#2594) https://github.com/python/cpython/commit/76d5abc8684bac4f2fc7cccfe2cd940923357351 |
|||
| msg301435 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2017年09月06日 03:06 | |
Sadly, Windows doesn't like much your big change. Just one example: 2>C:\buildbot.python.org3円.x.kloth-win64\build\Include\Python-ast.h(563): warning C4005: 'Yield': macro redefinition [C:\buildbot.python.org3円.x.kloth-win64\build\PCbuild\pythoncore.vcxproj] C:\Program Files (x86)\Windows Kits8円.1\Include\um\winbase.h(97): note: see previous definition of 'Yield' bltinmodule.c http://buildbot.python.org/all/builders/AMD64%20Windows7%20SP1%203.x/builds/954/steps/compile/logs/stdio |
|||
| msg301436 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2017年09月06日 03:37 | |
I'm also a bit skeptical about the header design in this PR. We should not to have a monolithic _Python.h header, and it should not be sometimes included in Python.h. Rather, code that needs the internal headers should include them directly. In fact, this PR regresses that by moving all the internal headers into Include/... |
|||
| msg301438 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2017年09月06日 04:43 | |
New changeset 05351c1bd8b70d1878527762174cdaaba3572395 by Eric Snow in branch 'master': Revert "bpo-30860: Consolidate stateful runtime globals." (#3379) https://github.com/python/cpython/commit/05351c1bd8b70d1878527762174cdaaba3572395 |
|||
| msg301599 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2017年09月07日 17:58 | |
Regarding the accidental exposure of _Py_CheckRecursionLimit, the main active usage of the stable ABI that we're aware of is Riverbank's C/C++ binding generator for PyQt: http://pyqt.sourceforge.net/Docs/sip4/directives.html#directive-%Module (see the use_limited_api option for the linked directive) I checked with Phil Thomson (sip's maintainer), and the bindings sip generates don't use either of the public macros that access this nominally private value. |
|||
| msg301679 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2017年09月08日 05:51 | |
New changeset 2ebc5ce42a8a9e047e790aefbf9a94811569b2b6 by Eric Snow in branch 'master': bpo-30860: Consolidate stateful runtime globals. (#3397) https://github.com/python/cpython/commit/2ebc5ce42a8a9e047e790aefbf9a94811569b2b6 |
|||
| msg301735 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2017年09月08日 21:27 | |
FYI, the merged code introduced a bunch of new warnings on Windows. I'm looking into it. |
|||
| msg301884 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2017年09月11日 16:31 | |
The commit 2ebc5ce42a8a9e047e790aefbf9a94811569b2b6 introduced reference leaks: see bpo-31420 which tracks them. |
|||
| msg301885 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2017年09月11日 16:34 | |
New changeset 4866957e86594935ec2e6434b6e470ebeb0c79b4 by Victor Stinner in branch 'master': bpo-30860: Add Include/internal/ in "make tags" (#3498) https://github.com/python/cpython/commit/4866957e86594935ec2e6434b6e470ebeb0c79b4 |
|||
| msg301927 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2017年09月12日 00:02 | |
New changeset ba6d5d1defd7a281c8c8804e4b4cfd7370886236 by Eric Snow in branch 'master': bpo-30860: Always provide serialno. (#3507) https://github.com/python/cpython/commit/ba6d5d1defd7a281c8c8804e4b4cfd7370886236 |
|||
| msg301931 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2017年09月12日 00:59 | |
New changeset 8728018624f257c7cfe44014742ae46134047f49 by Victor Stinner (Eric Snow) in branch 'master': bpo-30860: Fix a refleak. (#3506) https://github.com/python/cpython/commit/8728018624f257c7cfe44014742ae46134047f49 |
|||
| msg301935 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2017年09月12日 01:30 | |
New changeset fc1bf872e9d31f3e837f686210f94e57ad3d6582 by Eric Snow in branch 'master': bpo-30860: Move windows.h include out of internal/*.h. (#3458) https://github.com/python/cpython/commit/fc1bf872e9d31f3e837f686210f94e57ad3d6582 |
|||
| msg302153 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2017年09月14日 07:35 | |
New changeset dae0276bb6bc7281d59fb0b8f1aab31634ee80dc by Eric Snow in branch 'master': bpo-30860: Fix a refleak. (#3567) https://github.com/python/cpython/commit/dae0276bb6bc7281d59fb0b8f1aab31634ee80dc |
|||
| msg302216 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2017年09月14日 21:48 | |
New changeset ccb3c7654cc3d031fb93bf443a6ef9cfb11f6b43 by Victor Stinner in branch 'master': bpo-30860: Fix deadcode in obmalloc.c (#3499) https://github.com/python/cpython/commit/ccb3c7654cc3d031fb93bf443a6ef9cfb11f6b43 |
|||
| msg306888 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2017年11月24日 11:09 | |
New changeset 9e87e7776f7ace66baaf7247233afdabd00c2b44 by Victor Stinner in branch 'master': bpo-32096: Remove obj and mem from _PyRuntime (#4532) https://github.com/python/cpython/commit/9e87e7776f7ace66baaf7247233afdabd00c2b44 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:48 | admin | set | github: 75043 |
| 2017年11月24日 11:09:30 | vstinner | set | messages: + msg306888 |
| 2017年11月23日 23:11:54 | vstinner | set | pull_requests: + pull_request4468 |
| 2017年09月14日 23:57:39 | eric.snow | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2017年09月14日 21:48:39 | vstinner | set | messages: + msg302216 |
| 2017年09月14日 07:36:00 | eric.snow | set | messages: + msg302153 |
| 2017年09月14日 07:15:42 | eric.snow | set | pull_requests: + pull_request3556 |
| 2017年09月12日 01:30:46 | eric.snow | set | messages: + msg301935 |
| 2017年09月12日 00:59:24 | vstinner | set | messages: + msg301931 |
| 2017年09月12日 00:02:29 | eric.snow | set | messages: + msg301927 |
| 2017年09月11日 23:08:44 | eric.snow | set | pull_requests: + pull_request3501 |
| 2017年09月11日 22:54:11 | eric.snow | set | pull_requests: + pull_request3499 |
| 2017年09月11日 16:34:38 | vstinner | set | messages: + msg301885 |
| 2017年09月11日 16:31:25 | vstinner | set | messages: + msg301884 |
| 2017年09月11日 15:09:18 | vstinner | set | pull_requests: + pull_request3493 |
| 2017年09月11日 15:04:08 | vstinner | set | pull_requests: + pull_request3492 |
| 2017年09月08日 21:27:12 | eric.snow | set | messages: + msg301735 |
| 2017年09月08日 17:37:06 | eric.snow | set | keywords:
+ patch pull_requests: + pull_request3452 |
| 2017年09月08日 05:51:30 | eric.snow | set | messages: + msg301679 |
| 2017年09月07日 17:58:21 | ncoghlan | set | messages: + msg301599 |
| 2017年09月06日 22:31:03 | eric.snow | set | pull_requests: + pull_request3403 |
| 2017年09月06日 04:43:11 | eric.snow | set | messages: + msg301438 |
| 2017年09月06日 04:22:25 | eric.snow | set | pull_requests: - pull_request3387 |
| 2017年09月06日 04:14:37 | eric.snow | set | pull_requests: + pull_request3388 |
| 2017年09月06日 04:08:50 | eric.snow | set | pull_requests: + pull_request3387 |
| 2017年09月06日 03:37:55 | benjamin.peterson | set | nosy:
+ benjamin.peterson messages: + msg301436 |
| 2017年09月06日 03:06:58 | vstinner | set | messages: + msg301435 |
| 2017年09月06日 01:26:18 | eric.snow | set | messages: + msg301428 |
| 2017年07月07日 01:59:22 | ncoghlan | set | messages: + msg297851 |
| 2017年07月06日 22:08:39 | pitrou | set | nosy:
+ pitrou messages: + msg297848 |
| 2017年07月06日 13:54:01 | jkloth | set | nosy:
+ jkloth |
| 2017年07月06日 03:42:10 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg297794 |
| 2017年07月05日 21:12:49 | eric.snow | set | messages: + msg297782 |
| 2017年07月05日 21:10:39 | eric.snow | set | pull_requests: + pull_request2665 |
| 2017年07月05日 20:30:30 | eric.snow | create | |