This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nascheme
Recipients nascheme
Date 2021-08-15.21:02:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1629061343.65.0.828343713571.issue44897@roundup.psfhosted.org>
In-reply-to
Content
As I suspected, the performance impact is significant (although pretty small).  Based on Linux perf, it looks like the extra test+branch in _Py_Dealloc adds about 1% overhead.  pyperformance shows something similar, see attached reports (pypref-trashcan.txt and perf-annotate-trash.txt).

An idea I've been trying is to add another type slot, e.g. tp_call_dealloc.  It could be set by PyType_Ready().  It would be called by the Py_DECREF macro on refcnt going to zero.  If the object is non-GC and Py_TRACE_REFS is off, can make tp_call_dealloc actually be the tp_dealloc pointer.  If the type has the GC flag, point tp_call_dealloc to a _Py_Dealloc version that checks tp_is_gc and does the trashcan stuff.

Unfortunately, all types don't have PyType_Ready() called on them.  So, we cannot rely on tp_call_dealloc being set correctly.
History
Date User Action Args
2021-08-15 21:02:23naschemesetrecipients: + nascheme
2021-08-15 21:02:23naschemesetmessageid: <1629061343.65.0.828343713571.issue44897@roundup.psfhosted.org>
2021-08-15 21:02:23naschemelinkissue44897 messages
2021-08-15 21:02:23naschemecreate