[Python-Dev] No longer enable Py_TRACE_REFS by default in debug build (original) (raw)

Victor Stinner vstinner at redhat.com
Thu Apr 11 05:28:51 EDT 2019


Le jeu. 11 avr. 2019 à 07:49, Serhiy Storchaka <storchaka at gmail.com> a écrit :

10.04.19 14:01, Victor Stinner пише: > Disabling PyTRACEREFS by default in debug mode reduces the Python > memory footprint. PyTRACEREFS costs 2 pointers per PyObject: 16 > bytes on 64-bit platforms.

Does not the memory allocator in debug mode have even larger cost per allocated block?

What do you mean? That a debug build already waste too much memory and so doesn't deserve to have a smaller memory footprint? I'm not sure that I understand your point.

A smaller footprint can mean that more people may be able to use debug build. Disabling Py_TRACE_REFS should make Python a little bit faster.

My question stands: is it worth to keep a feature which "waste" resources (memory footprint and CPU) and nobody uses it?

Debug hooks add 4 x sizeof(size_t) bytes to every memory allocation to detect buffer underflow and buffer overflow. That's 32 bytes per memory allocation. By the way, IMHO the "serial number" is not really useful and could be removed to only add 3 x sizeof(size_t) (24 bytes). But the debug hook is very useful, it's common that it helps me to find real bugs in the code. Whereas I don't recall that Py_TRACE_REFS helped me even once.

Victor

Night gathers, and now my watch begins. It shall not end until my death.



More information about the Python-Dev mailing list