Re: [PATCH v12 03/19] perf annotate: Print the stats after the annotations

From: Arnaldo Carvalho de Melo

Date: Wed Nov 25 2026 - 13:41:27 EST


On Tue, Nov 24, 2026 at 02:19:51PM -0800, Namhyung Kim wrote:
> On Mon, Nov 23, 2026 at 07:00:08PM -0300, Arnaldo Carvalho de Melo wrote:
> > From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> >
> > With --code-with-type the instruction stats are printed from
> > hists__find_annotations() before that event is annotated: the first
> > event reports zeros and later events can report stale counts. The data
> > type total is only counted in --data-type mode, so --type-stat without
> > it is incomplete too.
>
> I prefer having type/insn stat before the result so that I can check the
> quality easily. But probably it makes sense to do it later when it's
> used with --code-with-type.

Done:

commit a33b6175c93c126c92bd1b98bd0760b39d79c234
Author: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Date: Thu Oct 29 11:20:31 2026 -0300

perf annotate: Print the stats where the counters are final

The stats are printed from hists__find_annotations(), before that event
is annotated: with --code-with-type the first event reports zeros,
because those types are resolved while printing, and a later event can
report a total that is not its own. The data type total is only
counted in --data-type mode, so --type-stat without it is incomplete
too.

The data type pass resolves the samples while the histograms are being
resorted, so in stdio without --code-with-type the counters are final
before any annotation is printed. Print the stats once there, before
the annotations, so that the quality can be checked without scrolling,
and once after them when --code-with-type or a browser is used, where
the counters only reach their final values during the output. Leave
the TUI's alternate screen before printing, so the stats remain on the
terminal. Warn if --type-stat is used without --data-type.

Fixes: 58824fa0087e1cb7 ("perf annotate: Add --insn-stat option for debugging")
Fixes: 61a9741e9f78c64c ("perf annotate: Add --type-stat option for debugging")
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

Still doing local LLM and container fleet builds to make sure everything
builds and tests in multiple arches before posting.

- Arnaldo