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 Mark.Shannon
Recipients Mark.Shannon
Date 2021-10-21.10:16:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1634811413.15.0.703765256195.issue45550@roundup.psfhosted.org>
In-reply-to
Content
Currently, we use the `tp_version_tag` as a proxy for the state of a class when specializing.
When we have issued 2**32 tags, we stop issuing tags. This prevents specializing of classes that need a new tag.

We can make a few enhancements:

1. Reserve the low 2**M (M probably 4 or 5) values for special classes. This would allow us to perform some type checks efficiently in a multiple-interpreter environment.
`PyLongCheck_Exact(ob)` is currently `Py_TYPE(ob) == &PyLong_Type` but could become `Py_TYPE(ob)->tp_version_tag == PY_INT_VERSION_TAG`. No need to access the interpreter state.

2. Reserve the low 2**N (N somewhere in range 10 to 16) for builtin classes. Maybe split this into immutable and mutable. 
We often need to load the version tag, this would save another load from tp_flags to check for builtin-ness and (im)mutability.

3. Add a modified count to the type struct. When this reaches a threshold, no longer issue tags for this class.
This would prevent pathological classes consuming millions of tags. Only needs 16 bits.

The reason we want power of two boundaries is so that we can test multiple types at once.
E.g. T1 and T2 are both "special" if `(T1->tp_version_tag | T2->tp_version_tag) < 2**M`
History
Date User Action Args
2021-10-21 10:16:53Mark.Shannonsetrecipients: + Mark.Shannon
2021-10-21 10:16:53Mark.Shannonsetmessageid: <1634811413.15.0.703765256195.issue45550@roundup.psfhosted.org>
2021-10-21 10:16:53Mark.Shannonlinkissue45550 messages
2021-10-21 10:16:52Mark.Shannoncreate