mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
GH-109329: Add tier 2 stats (GH-109913)
This commit is contained in:
parent
f7860295b1
commit
e561e98058
9 changed files with 483 additions and 128 deletions
|
@ -199,10 +199,6 @@ print_object_stats(FILE *out, ObjectStats *stats)
|
|||
fprintf(out, "Object method cache collisions: %" PRIu64 "\n", stats->type_cache_collisions);
|
||||
fprintf(out, "Object method cache dunder hits: %" PRIu64 "\n", stats->type_cache_dunder_hits);
|
||||
fprintf(out, "Object method cache dunder misses: %" PRIu64 "\n", stats->type_cache_dunder_misses);
|
||||
fprintf(out, "Optimization attempts: %" PRIu64 "\n", stats->optimization_attempts);
|
||||
fprintf(out, "Optimization traces created: %" PRIu64 "\n", stats->optimization_traces_created);
|
||||
fprintf(out, "Optimization traces executed: %" PRIu64 "\n", stats->optimization_traces_executed);
|
||||
fprintf(out, "Optimization uops executed: %" PRIu64 "\n", stats->optimization_uops_executed);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -215,6 +211,55 @@ print_gc_stats(FILE *out, GCStats *stats)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_histogram(FILE *out, const char *name, uint64_t hist[_Py_UOP_HIST_SIZE])
|
||||
{
|
||||
for (int i = 0; i < _Py_UOP_HIST_SIZE; i++) {
|
||||
fprintf(out, "%s[%" PRIu64"]: %" PRIu64 "\n", name, (uint64_t)1 << i, hist[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_optimization_stats(FILE *out, OptimizationStats *stats)
|
||||
{
|
||||
fprintf(out, "Optimization attempts: %" PRIu64 "\n", stats->attempts);
|
||||
fprintf(out, "Optimization traces created: %" PRIu64 "\n", stats->traces_created);
|
||||
fprintf(out, "Optimization traces executed: %" PRIu64 "\n", stats->traces_executed);
|
||||
fprintf(out, "Optimization uops executed: %" PRIu64 "\n", stats->uops_executed);
|
||||
fprintf(out, "Optimization trace stack overflow: %" PRIu64 "\n", stats->trace_stack_overflow);
|
||||
fprintf(out, "Optimization trace stack underflow: %" PRIu64 "\n", stats->trace_stack_underflow);
|
||||
fprintf(out, "Optimization trace too long: %" PRIu64 "\n", stats->trace_too_long);
|
||||
fprintf(out, "Optimization inner loop: %" PRIu64 "\n", stats->inner_loop);
|
||||
fprintf(out, "Optimization recursive call: %" PRIu64 "\n", stats->recursive_call);
|
||||
|
||||
print_histogram(out, "Trace length", stats->trace_length_hist);
|
||||
print_histogram(out, "Trace run length", stats->trace_run_length_hist);
|
||||
print_histogram(out, "Optimized trace length", stats->optimized_trace_length_hist);
|
||||
|
||||
const char* const* names;
|
||||
for (int i = 0; i < 512; i++) {
|
||||
if (i < 256) {
|
||||
names = _PyOpcode_OpName;
|
||||
} else {
|
||||
names = _PyOpcode_uop_name;
|
||||
}
|
||||
if (stats->opcode[i].execution_count) {
|
||||
fprintf(out, "uops[%s].execution_count : %" PRIu64 "\n", names[i], stats->opcode[i].execution_count);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
if (stats->unsupported_opcode[i]) {
|
||||
fprintf(
|
||||
out,
|
||||
"unsupported_opcode[%s].count : %" PRIu64 "\n",
|
||||
_PyOpcode_OpName[i],
|
||||
stats->unsupported_opcode[i]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_stats(FILE *out, PyStats *stats)
|
||||
{
|
||||
|
@ -222,6 +267,7 @@ print_stats(FILE *out, PyStats *stats)
|
|||
print_call_stats(out, &stats->call_stats);
|
||||
print_object_stats(out, &stats->object_stats);
|
||||
print_gc_stats(out, stats->gc_stats);
|
||||
print_optimization_stats(out, &stats->optimization_stats);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue