Skip to content

Classify specialization failures. Provides more useful stats, with lower overhead. #27701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Include/internal/pycore_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ int _Py_Specialize_BinarySubscr(PyObject *sub, PyObject *container, _Py_CODEUNIT
#define SPECIALIZATION_STATS_DETAILED 0
#define SPECIALIZATION_STATS_TO_FILE 0

#define SPECIALIZATION_FAILURE_KINDS 20

#if SPECIALIZATION_STATS

typedef struct _stats {
Expand All @@ -316,7 +318,7 @@ typedef struct _stats {
uint64_t deopt;
uint64_t unquickened;
#if SPECIALIZATION_STATS_DETAILED
PyObject *miss_types;
uint64_t specialization_failure_kinds[SPECIALIZATION_FAILURE_KINDS];
#endif
} SpecializationStats;

Expand Down
5 changes: 2 additions & 3 deletions Lib/test/test__opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ def test_specialization_stats(self):
stat_names + ['fails'])
for sn in stat_names:
self.assertIsInstance(stats['load_attr'][sn], int)
self.assertIsInstance(stats['load_attr']['fails'], dict)
for k,v in stats['load_attr']['fails'].items():
self.assertIsInstance(k, tuple)
self.assertIsInstance(stats['load_attr']['specialization_failure_kinds'], tuple)
for v in stats['load_attr']['specialization_failure_kinds']:
self.assertIsInstance(v, int)


Expand Down
Loading