[Python-Dev] Idea: reduce GC threshold in development mode (-X dev) (original) (raw)

Serhiy Storchaka storchaka at gmail.com
Fri Jun 8 06:36:24 EDT 2018


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



More information about the Python-Dev mailing list