[Python-Dev] Idea: reduce GC threshold in development mode (-X dev)
Ronald Oussoren
ronaldoussoren at mac.com
Fri Jun 8 09:22:01 EDT 2018
More information about the Python-Dev mailing list
Fri Jun 8 09:22:01 EDT 2018
- Previous message (by thread): [Python-Dev] Idea: reduce GC threshold in development mode (-X dev)
- Next message (by thread): [Python-Dev] Idea: reduce GC threshold in development mode (-X dev)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> On 8 Jun 2018, at 12:36, Serhiy Storchaka <storchaka at gmail.com> wrote: > > 08.06.18 11:31, Victor Stinner пише: >> Do you suggest to trigger a fake "GC collection" which would just >> visit all objects with a no-op visit callback? I like the idea! >> >> Yeah, that would help to detect objects in an inconsistent state and >> reuse the existing implemented visit methods of all types. >> >> Would you be interested to try to implement this new debug feature? > > It is simple: > > #ifdef Py_DEBUG > void > _PyGC_CheckConsistency(void) > { > int i; > if (_PyRuntime.gc.collecting) { > return; > } > _PyRuntime.gc.collecting = 1; > for (i = 0; i < NUM_GENERATIONS; ++i) { > update_refs(GEN_HEAD(i)); > } > for (i = 0; i < NUM_GENERATIONS; ++i) { > subtract_refs(GEN_HEAD(i)); > } > for (i = 0; i < NUM_GENERATIONS; ++i) { > revive_garbage(GEN_HEAD(i)); > } > _PyRuntime.gc.collecting = 0; > } > #endif Wouldn’t it be enough to visit just the the newly tracked object in PyObject_GC_Track with a visitor function that does something minimal to verify that the object value is sane, for example by checking PyType_Ready(Py_TYPE(op)). That would find issues where objects are tracked before they are initialised far enough to be save to visit, without changing GC behavior. I have no idea what the performance impact of this is though. Ronald -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180608/d54b3ea7/attachment-0001.html>
- Previous message (by thread): [Python-Dev] Idea: reduce GC threshold in development mode (-X dev)
- Next message (by thread): [Python-Dev] Idea: reduce GC threshold in development mode (-X dev)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list