bpo-46072: Add some object layout and allocation stats (GH-31051)

This commit is contained in:
Mark Shannon 2022-02-01 15:05:18 +00:00 committed by GitHub
parent 913e340a32
commit 48be46ec1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 1 deletions

View file

@ -305,9 +305,19 @@ typedef struct _call_stats {
uint64_t pyeval_calls;
} CallStats;
typedef struct _object_stats {
uint64_t allocations;
uint64_t frees;
uint64_t new_values;
uint64_t dict_materialized_on_request;
uint64_t dict_materialized_new_key;
uint64_t dict_materialized_too_big;
} ObjectStats;
typedef struct _stats {
OpcodeStats opcode_stats[256];
CallStats call_stats;
ObjectStats object_stats;
} PyStats;
extern PyStats _py_stats;
@ -316,6 +326,7 @@ extern PyStats _py_stats;
#define STAT_DEC(opname, name) _py_stats.opcode_stats[opname].specialization.name--
#define OPCODE_EXE_INC(opname) _py_stats.opcode_stats[opname].execution_count++
#define CALL_STAT_INC(name) _py_stats.call_stats.name++
#define OBJECT_STAT_INC(name) _py_stats.object_stats.name++
void _Py_PrintSpecializationStats(int to_file);
@ -326,6 +337,7 @@ PyAPI_FUNC(PyObject*) _Py_GetSpecializationStats(void);
#define STAT_DEC(opname, name) ((void)0)
#define OPCODE_EXE_INC(opname) ((void)0)
#define CALL_STAT_INC(name) ((void)0)
#define OBJECT_STAT_INC(name) ((void)0)
#endif