[Python-Dev] Add a developer mode to Python: -X dev command line option (original) (raw)
Victor Stinner victor.stinner at gmail.com
Thu Nov 16 07:48:41 EST 2017
- Previous message (by thread): [Python-Dev] Add a developer mode to Python: -X dev command line option
- Next message (by thread): [Python-Dev] Add a developer mode to Python: -X dev command line option
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2017-11-16 13:11 GMT+01:00 Antoine Pitrou <solipsis at pitrou.net>:
Could you measure and perhaps document the expected effect on performance and memory consumption? (it can be a very rough ballpart estimate)
Currently "python3 -X dev script.py" behaves as "PYTHONMALLOC=debug python3 -W default -X faulthandler script.py".
faulthandler has a negligible cost on performance/memory.
For -W default, I guess that your question is the cost on emitting a warning: overhead when a warning is displayed, and overhead when the warning is filtered. Right?
IMHO the most expensive check is PYTHONMALLOC=debug which increases a lot the memory usage.
You can measure the difference using tracemalloc and PYTHONMALLOC:
haypo at selma$ PYTHONMALLOC=debug ./python -X tracemalloc -i -m test test_os (...)
import tracemalloc; tracemalloc.gettracedmemory() (10719623, 10981725)
haypo at selma$ PYTHONMALLOC=debug ./python -X tracemalloc -i -m test test_os (...)
import tracemalloc; tracemalloc.gettracedmemory() (10724064, 16577338)
For example, on test_os, PYTHONMALLOC=debug increases the peak memory usage from 10.5 MiB to 15.8 MiB: +50%.
PYTHONMALLOC=debug adds 4 * sizeof(size_t) bytes to each allocated memory block. For example, an empty tuple uses 64 bytes, but PYTHONMALLOC=debug allocates 96 bytes (+ 32 bytes) in 64-bit mode.
Victor
- Previous message (by thread): [Python-Dev] Add a developer mode to Python: -X dev command line option
- Next message (by thread): [Python-Dev] Add a developer mode to Python: -X dev command line option
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]