Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita4460f2

Browse files
authored
Split refcount stats into 'interpreter' and 'non-interpreter' (GH-92919)
1 parent3fa0237 commita4460f2

File tree

6 files changed

+24
-0
lines changed

6 files changed

+24
-0
lines changed

‎Include/pystats.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ typedef struct _call_stats {
3636
typedefstruct_object_stats {
3737
uint64_tincrefs;
3838
uint64_tdecrefs;
39+
uint64_tinterpreter_increfs;
40+
uint64_tinterpreter_decrefs;
3941
uint64_tallocations;
4042
uint64_tallocations512;
4143
uint64_tallocations4k;
@@ -60,10 +62,18 @@ PyAPI_DATA(PyStats) _py_stats;
6062

6163
externvoid_Py_PrintSpecializationStats(intto_file);
6264

65+
#ifdef_PY_INTERPRETER
66+
67+
#define_Py_INCREF_STAT_INC() _py_stats.object_stats.interpreter_increfs++
68+
#define_Py_DECREF_STAT_INC() _py_stats.object_stats.interpreter_decrefs++
69+
70+
#else
6371

6472
#define_Py_INCREF_STAT_INC() _py_stats.object_stats.increfs++
6573
#define_Py_DECREF_STAT_INC() _py_stats.object_stats.decrefs++
6674

75+
#endif
76+
6777
#else
6878

6979
#define_Py_INCREF_STAT_INC() ((void)0)

‎Objects/genobject.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* Generator object implementation */
22

3+
#define_PY_INTERPRETER
4+
35
#include"Python.h"
46
#include"pycore_call.h"// _PyObject_CallNoArgs()
57
#include"pycore_ceval.h"// _PyEval_EvalFrame()

‎Python/ceval.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
XXX document it!
66
*/
77

8+
#define_PY_INTERPRETER
9+
810
#include"Python.h"
911
#include"pycore_abstract.h"// _PyIndex_Check()
1012
#include"pycore_call.h"// _PyObject_FastCallDictTstate()

‎Python/frame.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
#define_PY_INTERPRETER
3+
24
#include"Python.h"
35
#include"frameobject.h"
46
#include"pycore_code.h"// stats

‎Python/specialize.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ print_object_stats(FILE *out, ObjectStats *stats)
191191
fprintf(out,"Object allocations over 4 kbytes: %"PRIu64"\n",stats->allocations_big);
192192
fprintf(out,"Object frees: %"PRIu64"\n",stats->frees);
193193
fprintf(out,"Object new values: %"PRIu64"\n",stats->new_values);
194+
fprintf(out,"Object interpreter increfs: %"PRIu64"\n",stats->interpreter_increfs);
195+
fprintf(out,"Object interpreter decrefs: %"PRIu64"\n",stats->interpreter_decrefs);
194196
fprintf(out,"Object increfs: %"PRIu64"\n",stats->increfs);
195197
fprintf(out,"Object decrefs: %"PRIu64"\n",stats->decrefs);
196198
fprintf(out,"Object materialize dict (on request): %"PRIu64"\n",stats->dict_materialized_on_request);

‎Tools/scripts/summarize_stats.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,19 @@ def emit_object_stats(stats):
272272
withSection("Object stats",summary="allocations, frees and dict materializatons"):
273273
total_materializations=stats.get("Object new values")
274274
total_allocations=stats.get("Object allocations")
275+
total_increfs=stats.get("Object interpreter increfs")+stats.get("Object increfs")
276+
total_decrefs=stats.get("Object interpreter decrefs")+stats.get("Object decrefs")
275277
rows= []
276278
forkey,valueinstats.items():
277279
ifkey.startswith("Object"):
278280
if"materialize"inkey:
279281
ratio=f"{100*value/total_materializations:0.1f}%"
280282
elif"allocations"inkey:
281283
ratio=f"{100*value/total_allocations:0.1f}%"
284+
elif"increfs"inkey:
285+
ratio=f"{100*value/total_increfs:0.1f}%"
286+
elif"decrefs"inkey:
287+
ratio=f"{100*value/total_decrefs:0.1f}%"
282288
else:
283289
ratio=""
284290
label=key[6:].strip()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp