From: Namhyung Kim <namhyung@kernel.org>
To: Fengkai Sun <qcloud1014@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: Toggle perf stat on/off periodically and keep each sample
Date: Thu, 17 Oct 2024 15:26:46 -0700 [thread overview]
Message-ID: <ZxGPJpbElYMQhQDX@google.com> (raw)
In-Reply-To: <CAF6YOcNRt1=Dgw85QtVgwOY1QYTOd9E=V4Vr9xY2cjZp5n+bgw@mail.gmail.com>
Hello,
On Wed, Oct 16, 2024 at 09:28:33AM +0800, Fengkai Sun wrote:
> Hi all,
>
> I've been using control fd and delay=-1 to toggle perf stat on until a
> certain point of the program, and it works like a charm.
>
> Now, I want to do this periodically and keep all the results.
> Specifically, I have a performance-critical network program that reads
> the packets in batches and processes them, and I want to record the
> hardware counters on each batch, for future comparison.
>
> Intuitively, this requires two functionalities I have no idea how to achieve:
>
> 1. The ability to zero out all recorded counters when the current
> sample is finished and
> 2. The ability to keep individual samples, instead of outputting a
> single overall result when the process finishes.
>
> I'm wondering if this can be achieved under current version of perf,
> and if such recording makes sense (e.g., does not incur too much
> overhead). Thank you!
I think you are looking for something like interval mode like -I 1000.
$ sudo perf stat -a -I 1000 -e cycles,instructions sleep 5
# time counts unit events
1.001064439 644,313,943 cycles
1.001064439 548,175,426 instructions # 0.85 insn per cycle
2.002682133 570,454,723 cycles
2.002682133 426,891,566 instructions # 0.75 insn per cycle
3.004412672 565,162,161 cycles
3.004412672 351,875,655 instructions # 0.62 insn per cycle
4.006131920 463,748,461 cycles
4.006131920 239,702,866 instructions # 0.52 insn per cycle
5.001878221 466,409,911 cycles
5.001878221 235,684,130 instructions # 0.51 insn per cycle
Of course it doesn't turn the events on and off. But is it something
similar to what you want?
Thanks,
Namhyung
next prev parent reply other threads:[~2024-10-17 22:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-16 1:28 Toggle perf stat on/off periodically and keep each sample Fengkai Sun
2024-10-17 22:26 ` Namhyung Kim [this message]
2024-10-18 14:19 ` Fengkai Sun
2024-10-18 16:08 ` Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZxGPJpbElYMQhQDX@google.com \
--to=namhyung@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=qcloud1014@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.