All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Joanne Koong <joannekoong@fb.com>
Cc: bpf <bpf@vger.kernel.org>, Andrii Nakryiko <andrii@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <Kernel-team@fb.com>
Subject: Re: [PATCH v3 bpf-next 3/4] selftests/bpf: measure bpf_loop verifier performance
Date: Mon, 29 Nov 2021 14:55:36 -0800	[thread overview]
Message-ID: <CAEf4BzbSbYow+SmiggZtd0sD32zV0xA+b6itv-aOprKpmDiZgw@mail.gmail.com> (raw)
In-Reply-To: <20211129223725.2770730-4-joannekoong@fb.com>

On Mon, Nov 29, 2021 at 2:39 PM Joanne Koong <joannekoong@fb.com> wrote:
>
> This patch tests bpf_loop in pyperf and strobemeta, and measures the
> verifier performance of replacing the traditional for loop
> with bpf_loop.
>
> The results are as follows:
>
> ~strobemeta~
>
> Baseline
>     verification time 6808200 usec
>     stack depth 496
>     processed 554252 insns (limit 1000000) max_states_per_insn 16
>     total_states 15878 peak_states 13489  mark_read 3110
>     #192 verif_scale_strobemeta:OK (unrolled loop)
>
> Using bpf_loop
>     verification time 31589 usec
>     stack depth 96+400
>     processed 1513 insns (limit 1000000) max_states_per_insn 2
>     total_states 106 peak_states 106 mark_read 60
>     #193 verif_scale_strobemeta_bpf_loop:OK
>
> ~pyperf600~
>
> Baseline
>     verification time 29702486 usec
>     stack depth 368
>     processed 626838 insns (limit 1000000) max_states_per_insn 7
>     total_states 30368 peak_states 30279 mark_read 748
>     #182 verif_scale_pyperf600:OK (unrolled loop)
>
> Using bpf_loop
>     verification time 148488 usec
>     stack depth 320+40
>     processed 10518 insns (limit 1000000) max_states_per_insn 10
>     total_states 705 peak_states 517 mark_read 38
>     #183 verif_scale_pyperf600_bpf_loop:OK
>
> Using the bpf_loop helper led to approximately a 99% decrease
> in the verification time and in the number of instructions.
>
> Signed-off-by: Joanne Koong <joannekoong@fb.com>
> ---

Acked-by: Andrii Nakryiko <andrii@kernel.org>

>  .../bpf/prog_tests/bpf_verif_scale.c          | 12 +++
>  tools/testing/selftests/bpf/progs/pyperf.h    | 71 +++++++++++++++++-
>  .../selftests/bpf/progs/pyperf600_bpf_loop.c  |  6 ++
>  .../testing/selftests/bpf/progs/strobemeta.h  | 75 ++++++++++++++++++-
>  .../selftests/bpf/progs/strobemeta_bpf_loop.c |  9 +++
>  5 files changed, 169 insertions(+), 4 deletions(-)
>  create mode 100644 tools/testing/selftests/bpf/progs/pyperf600_bpf_loop.c
>  create mode 100644 tools/testing/selftests/bpf/progs/strobemeta_bpf_loop.c
>

[...]

>                 /* Unwind python stack */
>                 for (int i = 0; i < STACK_MAX_LEN; ++i) {
>                         if (frame_ptr && get_frame_data(frame_ptr, pidData, &frame, &sym)) {
> @@ -251,6 +319,7 @@ int __on_event(struct bpf_raw_tracepoint_args *ctx)
>                                 frame_ptr = frame.f_back;
>                         }
>                 }
> +#endif /* USE_BPF_LOOP */
>                 event->stack_complete = frame_ptr == NULL;
>         } else {
>                 event->stack_complete = 1;
> diff --git a/tools/testing/selftests/bpf/progs/pyperf600_bpf_loop.c b/tools/testing/selftests/bpf/progs/pyperf600_bpf_loop.c
> new file mode 100644
> index 000000000000..bde8baed4ca6
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/pyperf600_bpf_loop.c
> @@ -0,0 +1,6 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (c) 2021 Facebook

nit: should be /* ... */

> +
> +#define STACK_MAX_LEN 600
> +#define USE_BPF_LOOP
> +#include "pyperf.h"

[...]

> diff --git a/tools/testing/selftests/bpf/progs/strobemeta_bpf_loop.c b/tools/testing/selftests/bpf/progs/strobemeta_bpf_loop.c
> new file mode 100644
> index 000000000000..e6f9f920e68a
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/strobemeta_bpf_loop.c
> @@ -0,0 +1,9 @@
> +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
> +// Copyright (c) 2021 Facebook

same

> +
> +#define STROBE_MAX_INTS 2
> +#define STROBE_MAX_STRS 25
> +#define STROBE_MAX_MAPS 100
> +#define STROBE_MAX_MAP_ENTRIES 20
> +#define USE_BPF_LOOP
> +#include "strobemeta.h"
> --
> 2.30.2
>

  reply	other threads:[~2021-11-29 23:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-29 22:37 [PATCH v3 bpf-next 0/4] Add bpf_loop helper Joanne Koong
2021-11-29 22:37 ` [PATCH v3 bpf-next 1/4] bpf: " Joanne Koong
2021-11-29 22:48   ` Andrii Nakryiko
2021-11-30 16:54   ` Toke Høiland-Jørgensen
2021-11-29 22:37 ` [PATCH v3 bpf-next 2/4] selftests/bpf: Add bpf_loop test Joanne Koong
2021-11-29 22:52   ` Andrii Nakryiko
2021-11-29 22:37 ` [PATCH v3 bpf-next 3/4] selftests/bpf: measure bpf_loop verifier performance Joanne Koong
2021-11-29 22:55   ` Andrii Nakryiko [this message]
2021-11-29 22:37 ` [PATCH v3 bpf-next 4/4] selftest/bpf/benchs: add bpf_loop benchmark Joanne Koong
2021-11-29 23:02   ` Andrii Nakryiko
2021-11-30 16:53   ` Toke Høiland-Jørgensen

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=CAEf4BzbSbYow+SmiggZtd0sD32zV0xA+b6itv-aOprKpmDiZgw@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=Kernel-team@fb.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=joannekoong@fb.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.