Skip to content

Commit 23e4f80

Browse files
authored
A few minor tweaks to get stats working and compiling cleanly. (#117219)
Fixes a compilation error when configured with `--enable-pystats`, an array size issue, and an unused variable.
1 parent 507896d commit 23e4f80

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

Include/cpython/pystats.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ typedef struct _optimization_stats {
118118
uint64_t recursive_call;
119119
uint64_t low_confidence;
120120
uint64_t executors_invalidated;
121-
UOpStats opcode[MAX_UOP_ID];
121+
UOpStats opcode[MAX_UOP_ID+1];
122122
uint64_t unsupported_opcode[256];
123123
uint64_t trace_length_hist[_Py_UOP_HIST_SIZE];
124124
uint64_t trace_run_length_hist[_Py_UOP_HIST_SIZE];
@@ -128,7 +128,7 @@ typedef struct _optimization_stats {
128128
uint64_t optimizer_failure_reason_no_memory;
129129
uint64_t remove_globals_builtins_changed;
130130
uint64_t remove_globals_incorrect_keys;
131-
uint64_t error_in_opcode[MAX_UOP_ID];
131+
uint64_t error_in_opcode[MAX_UOP_ID+1];
132132
} OptimizationStats;
133133

134134
typedef struct _rare_event_stats {

Python/gc.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,6 @@ gc_collect_young(PyThreadState *tstate,
12851285
for (gc = GC_NEXT(young); gc != young; gc = GC_NEXT(gc)) {
12861286
count++;
12871287
}
1288-
GC_STAT_ADD(0, objects_queued, count);
12891288
}
12901289
#endif
12911290

@@ -1422,7 +1421,6 @@ gc_collect_increment(PyThreadState *tstate, struct gc_collection_stats *stats)
14221421
gc_set_old_space(gc, gcstate->visited_space);
14231422
increment_size += expand_region_transitively_reachable(&increment, gc, gcstate);
14241423
}
1425-
GC_STAT_ADD(1, objects_queued, region_size);
14261424
PyGC_Head survivors;
14271425
gc_list_init(&survivors);
14281426
gc_collect_region(tstate, &increment, &survivors, UNTRACK_TUPLES, stats);
@@ -1805,10 +1803,10 @@ _PyGC_Collect(PyThreadState *tstate, int generation, _PyGC_Reason reason)
18051803
_PyErr_SetRaisedException(tstate, exc);
18061804
GC_STAT_ADD(generation, objects_collected, stats.collected);
18071805
#ifdef Py_STATS
1808-
if (_py_stats) {
1806+
if (_Py_stats) {
18091807
GC_STAT_ADD(generation, object_visits,
1810-
_py_stats->object_stats.object_visits);
1811-
_py_stats->object_stats.object_visits = 0;
1808+
_Py_stats->object_stats.object_visits);
1809+
_Py_stats->object_stats.object_visits = 0;
18121810
}
18131811
#endif
18141812
validate_old(gcstate);

Python/specialize.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ print_optimization_stats(FILE *out, OptimizationStats *stats)
250250
fprintf(out, "Optimizer remove globals builtins changed: %" PRIu64 "\n", stats->remove_globals_builtins_changed);
251251
fprintf(out, "Optimizer remove globals incorrect keys: %" PRIu64 "\n", stats->remove_globals_incorrect_keys);
252252

253-
const char* const* names;
254253
for (int i = 0; i <= MAX_UOP_ID; i++) {
255254
if (stats->opcode[i].execution_count) {
256255
fprintf(out, "uops[%s].execution_count : %" PRIu64 "\n", _PyUOpName(i), stats->opcode[i].execution_count);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy