You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enhance Python's Memory Instrumentation with COUNT_ALLOCS #77239
changed the title [-][WIP] Enhance Python's Memory Instrumentation with COUNT_ALLCOS[/-][+]Enhance Python's Memory Instrumentation with COUNT_ALLOCS[/+]on Mar 12, 2018
eduardo-elizondo commented on Mar 12, 2018
eduardo-elizondomannequin
MannequinAuthor
More actions
Currently, Python has very few instrumentation when it comes to the types of allocations that it's doing. For instance, we currently can't identify how many times an object uses free lists vs actual mallocs.
Currently, there's a special build which can be used by compiling with "-DCOUNT_ALLOCS". However, this build is not ABI compatible with extensions. Meaning you have to recompile all the modules that are used. Doing this on a large scale scenario (1000+ modules) is not feasible.
Thus, I propose the following enhancements:
Make COUNT_ALLOCS ABI compatible
Then:
Expand the counters to not only track allocs and frees but also distinguish between:
GC Counts: Allocs/Frees coming from PyObject_GC_Malloc PyObject_GC_Del
Memory Counts: Allocs/Frees coming from PyMem_Malloc/PyObject_Malloc PyObject_Free (modulo GC objects).
Free Lists: "Allocs/Frees" coming from specific object's free_lists/caches.
Misc: Extra kinds of "Allocs/Frees" such as code's zombie frame.
Activity
[-]Enhancing Python[/-][+][WIP] Enhancing Python's COUNT_ALLOCS[/+][-][WIP] Enhancing Python's COUNT_ALLOCS[/-][+][WIP] Enhance Python's Memory Instrumentation with COUNT_ALLCOS[/+]eduardo-elizondo commentedon Mar 12, 2018
[WIP]
[-][WIP] Enhance Python's Memory Instrumentation with COUNT_ALLCOS[/-][+]Enhance Python's Memory Instrumentation with COUNT_ALLOCS[/+]eduardo-elizondo commentedon Mar 12, 2018
Currently, Python has very few instrumentation when it comes to the types of allocations that it's doing. For instance, we currently can't identify how many times an object uses free lists vs actual mallocs.
Currently, there's a special build which can be used by compiling with "-DCOUNT_ALLOCS". However, this build is not ABI compatible with extensions. Meaning you have to recompile all the modules that are used. Doing this on a large scale scenario (1000+ modules) is not feasible.
Thus, I propose the following enhancements:
Then:
serhiy-storchaka commentedon Mar 12, 2018
Could tracemalloc help you?
eduardo-elizondo commentedon Mar 12, 2018
@serhiy.storchaka tracemalloc can't distinguish between the usage of gc allocs, normal mallocs, and free list reuse.
iritkatriel commentedon Jan 31, 2023
The PR was closed by the OP in 2019. Closing this as well.
vstinner commentedon Apr 5, 2023
The COUNT_ALLOCS special build was removed in Python 3.9: #83670