Re: [RFC PATCH v4 2/6] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric.

From: Andi Kleen
Date: Wed Mar 13 2024 - 20:00:49 EST


> We could use -a -C and cgroup together. I think this could be a useful use case.
> There could be other improvement to the implementation in next step. But I believe

I don't know how you would improve it. A lot of the problems are fairly
fundamental.

> current implementation could provide users the access to our new feature with
> accurate results
> and without adding too much overhead.

perf record increases the overhead a lot over a perf stat! Sampling
is much more expensive than counting.

That should be at least a order of magnitude difference.
Another advantage of doing it separately.

That will also make it inaccurate.

Please do a proper implementation. This one is no good.

You can likely reuse a lot of your code:

- Add a perf calibrate to run the profile step separately that generates the JSON
- Add a --metrics option to perf to read the resulting JSON
- Add some mechanism to read a default JSON as fallback. I guess this
one could be compiled in to avoid a dependency on an installed file.

-Andi