8000 Classify specialization failures. Provides more useful stats, with lo… · python/cpython@9816777 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9816777

Browse files
authored
Classify specialization failures. Provides more useful stats, with lower overhead. (GH-27701)
1 parent c7ea1e3 commit 9816777

File tree

4 files changed

+100
-100
lines changed

4 files changed

+100
-100
lines changed

Include/internal/pycore_code.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ int _Py_Specialize_BinarySubscr(PyObject *sub, PyObject *container, _Py_CODEUNIT
305305
#define SPECIALIZATION_STATS_DETAILED 0
306306
#define SPECIALIZATION_STATS_TO_FILE 0
307307

308+
#define SPECIALIZATION_FAILURE_KINDS 20
309+
308310
#if SPECIALIZATION_STATS
309311

310312
typedef struct _stats {
@@ -316,7 +318,7 @@ typedef struct _stats {
316318
uint64_t deopt;
317319
uint64_t unquickened;
318320
#if SPECIALIZATION_STATS_DETAILED
319-
PyObject *miss_types;
321+
uint64_t specialization_failure_kinds[SPECIALIZATION_FAILURE_KINDS];
320322
#endif
321323
} SpecializationStats;
322324

Lib/test/test__opcode.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ def test_specialization_stats(self):
8585
stat_names + ['fails'])
8686
for sn in stat_names:
8787
self.assertIsInstance(stats['load_attr'][sn], int)
88-
self.assertIsInstance(stats['load_attr']['fails'], dict)
89-
for k,v in stats['load_attr']['fails'].items():
90-
self.assertIsInstance(k, tuple)
88+
self.assertIsI 54C6 nstance(stats['load_attr']['specialization_failure_kinds'], tuple)
89+
for v in stats['load_attr']['specialization_failure_kinds']:
9190
self.assertIsInstance(v, int)
9291

9392

0 commit comments

Comments
 (0)
0