From: Yonghong Song <yhs@fb.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Andrii Nakryiko <andriin@fb.com>, bpf <bpf@vger.kernel.org>,
Networking <netdev@vger.kernel.org>,
Alexei Starovoitov <ast@fb.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Kernel Team <kernel-team@fb.com>,
John Fastabend <john.fastabend@gmail.com>
Subject: Re: [PATCH v2 bpf-next 2/3] selftest/bpf: fmod_ret prog and implement test_overhead as part of bench
Date: Tue, 12 May 2020 10:47:40 -0700 [thread overview]
Message-ID: <f06414a3-cd74-2223-8d15-bed62744b891@fb.com> (raw)
In-Reply-To: <CAEf4BzY71QEmq74B8y-AmW1LFhFZ35TwO5vLn4AOiJPOSVqtjw@mail.gmail.com>
On 5/12/20 10:23 AM, Andrii Nakryiko wrote:
> On Tue, May 12, 2020 at 8:11 AM Yonghong Song <yhs@fb.com> wrote:
>>
>>
>>
>> On 5/11/20 9:22 PM, Andrii Nakryiko wrote:
>>> On Sat, May 9, 2020 at 10:24 AM Yonghong Song <yhs@fb.com> wrote:
>>>>
>>>>
>>>>
>>>> On 5/8/20 4:20 PM, Andrii Nakryiko wrote:
>>>>> Add fmod_ret BPF program to existing test_overhead selftest. Also re-implement
>>>>> user-space benchmarking part into benchmark runner to compare results. Results
>>>>> with ./bench are consistently somewhat lower than test_overhead's, but relative
>>>>> performance of various types of BPF programs stay consisten (e.g., kretprobe is
>>>>> noticeably slower).
>>>>>
>>>>> run_bench_rename.sh script (in benchs/ directory) was used to produce the
>>>>> following numbers:
>>>>>
>>>>> base : 3.975 ± 0.065M/s
>>>>> kprobe : 3.268 ± 0.095M/s
>>>>> kretprobe : 2.496 ± 0.040M/s
>>>>> rawtp : 3.899 ± 0.078M/s
>>>>> fentry : 3.836 ± 0.049M/s
>>>>> fexit : 3.660 ± 0.082M/s
>>>>> fmodret : 3.776 ± 0.033M/s
>>>>>
>>>>> While running test_overhead gives:
>>>>>
>>>>> task_rename base 4457K events per sec
>>>>> task_rename kprobe 3849K events per sec
>>>>> task_rename kretprobe 2729K events per sec
>>>>> task_rename raw_tp 4506K events per sec
>>>>> task_rename fentry 4381K events per sec
>>>>> task_rename fexit 4349K events per sec
>>>>> task_rename fmod_ret 4130K events per sec
>>>>
>>>> Do you where the overhead is and how we could provide options in
>>>> bench to reduce the overhead so we can achieve similar numbers?
>>>> For benchmarking, sometimes you really want to see "true"
>>>> potential of a particular implementation.
>>>
>>> Alright, let's make it an official bench-off... :) And the reason for
>>> this discrepancy, turns out to be... not atomics at all! But rather a
>>> single-threaded vs multi-threaded process (well, at least task_rename
>>> happening from non-main thread, I didn't narrow it down further).
>>
>> It would be good to find out why and have a scheme (e.g. some kind
>> of affinity binding) to close the gap.
>
> I don't think affinity has anything to do with this. test_overhead
> sets affinity for entire process, and that doesn't change results at
> all. Same for bench, both with and without setting affinity, results
> are pretty much the same. Affinity helps a bit to get a bit more
> stable and consistent results, but doesn't hurt or help performance
> for this benchmark.
>
> I don't think we need to spend that much time trying to understand
> behavior of task renaming for such a particular setup. Benchmarking
> has to be multi-threaded in most cases anyways, there is no way around
> that.
Okay. This might be related to kernel scheduling of main thread vs.
secondary threads? This then indeed beyond this patch.
I am fine with the current mechanism as is. Maybe put the above
experimental data in commit message? If later other people
want to do further investigation, they have some data to
start with.
>
>>
>>> Atomics actually make very little difference, which gives me a good
>>> peace of mind :)
>>>
>>> So, I've built and ran test_overhead (selftest) and bench both as
>>> multi-threaded and single-threaded apps. Corresponding results match
>>> almost perfectly. And that's while test_overhead doesn't use atomics
>>> at all, while bench still does. Then I also ran test_overhead with
>>> added generics to match bench implementation. There are barely any
>>> differences, see two last sets of results.
>>>
>>> BTW, selftest results seems bit lower from the ones in original
>>> commit, probably because I made it run more iterations (like 40 times
>>> more) to have more stable results.
>>>
>>> So here are the results:
>>>
>>> Single-threaded implementations
>>> ===============================
>>>
>>> /* bench: single-threaded, atomics */
>>> base : 4.622 ± 0.049M/s
>>> kprobe : 3.673 ± 0.052M/s
>>> kretprobe : 2.625 ± 0.052M/s
>>> rawtp : 4.369 ± 0.089M/s
>>> fentry : 4.201 ± 0.558M/s
>>> fexit : 4.309 ± 0.148M/s
>>> fmodret : 4.314 ± 0.203M/s
>>>
>>> /* selftest: single-threaded, no atomics */
>>> task_rename base 4555K events per sec
>>> task_rename kprobe 3643K events per sec
>>> task_rename kretprobe 2506K events per sec
>>> task_rename raw_tp 4303K events per sec
>>> task_rename fentry 4307K events per sec
>>> task_rename fexit 4010K events per sec
>>> task_rename fmod_ret 3984K events per sec
>>>
>>>
>>> Multi-threaded implementations
>>> ==============================
>>>
>>> /* bench: multi-threaded w/ atomics */
>>> base : 3.910 ± 0.023M/s
>>> kprobe : 3.048 ± 0.037M/s
>>> kretprobe : 2.300 ± 0.015M/s
>>> rawtp : 3.687 ± 0.034M/s
>>> fentry : 3.740 ± 0.087M/s
>>> fexit : 3.510 ± 0.009M/s
>>> fmodret : 3.485 ± 0.050M/s
>>>
>>> /* selftest: multi-threaded w/ atomics */
>>> task_rename base 3872K events per sec
>>> task_rename kprobe 3068K events per sec
>>> task_rename kretprobe 2350K events per sec
>>> task_rename raw_tp 3731K events per sec
>>> task_rename fentry 3639K events per sec
>>> task_rename fexit 3558K events per sec
>>> task_rename fmod_ret 3511K events per sec
>>>
>>> /* selftest: multi-threaded, no atomics */
>>> task_rename base 3945K events per sec
>>> task_rename kprobe 3298K events per sec
>>> task_rename kretprobe 2451K events per sec
>>> task_rename raw_tp 3718K events per sec
>>> task_rename fentry 3782K events per sec
>>> task_rename fexit 3543K events per sec
>>> task_rename fmod_ret 3526K events per sec
>>>
>>>
>> [...]
next prev parent reply other threads:[~2020-05-12 17:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-08 23:20 [PATCH v2 bpf-next 0/3] Add benchmark runner and few benchmarks Andrii Nakryiko
2020-05-08 23:20 ` [PATCH v2 bpf-next 1/3] selftests/bpf: add benchmark runner infrastructure Andrii Nakryiko
2020-05-09 17:10 ` Yonghong Song
2020-05-12 3:29 ` Andrii Nakryiko
2020-05-12 14:39 ` Yonghong Song
2020-05-08 23:20 ` [PATCH v2 bpf-next 2/3] selftest/bpf: fmod_ret prog and implement test_overhead as part of bench Andrii Nakryiko
2020-05-09 17:23 ` Yonghong Song
2020-05-12 4:22 ` Andrii Nakryiko
2020-05-12 15:11 ` Yonghong Song
2020-05-12 17:23 ` Andrii Nakryiko
2020-05-12 17:47 ` Yonghong Song [this message]
2020-05-08 23:20 ` [PATCH v2 bpf-next 3/3] selftest/bpf: add BPF triggering benchmark Andrii Nakryiko
2020-05-09 17:43 ` Yonghong Song
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=f06414a3-cd74-2223-8d15-bed62744b891@fb.com \
--to=yhs@fb.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andriin@fb.com \
--cc=ast@fb.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).