[Python-Dev] No longer enable Py_TRACE_REFS by default in debug build
Le jeu. 11 avr. 2019 ? 07:49, Serhiy Storchaka <storchaka at gmail.com> a ?crit :
> 10.04.19 14:01, Victor Stinner ????:
> > Disabling Py_TRACE_REFS by default in debug mode reduces the Python
> > memory footprint. Py_TRACE_REFS 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.
Night gathers, and now my watch begins. It shall not end until my death.