From: Eduard Zingerman <eddyz87@gmail.com>
To: Ihor Solodrai <ihor.solodrai@pm.me>,
dwarves@vger.kernel.org, acme@kernel.org
Cc: bpf@vger.kernel.org, alan.maguire@oracle.com, andrii@kernel.org,
mykolal@fb.com
Subject: Re: [RFC PATCH 9/9] pahole: faster reproducible BTF encoding
Date: Fri, 29 Nov 2024 16:17:41 -0800 [thread overview]
Message-ID: <450a352e713902e4fa091163d283b91786fb8605.camel@gmail.com> (raw)
In-Reply-To: <20241128012341.4081072-10-ihor.solodrai@pm.me>
On Thu, 2024-11-28 at 01:24 +0000, Ihor Solodrai wrote:
> Change multithreaded implementation of BTF encoding:
>
> * Use a single btf_encoder accumulating BTF for all compilation units
> * Make BTF encoding routine exclusive: only one thread at a time may
> execute btf_encoder__encode_cu
> * Introduce CU ids: an id is an index of a CU, in order they are
> created in dwarf_loader.c
> * Introduce CU__PROCESSED cu_state to inidicate what CUs have been
> processed by the encoder
> * Enforce encoding order of compilation units (struct cu) loaded
> from DWARF by utilizing global struct cus as a queue
> * reproducible_build option is now moot: BTF encoding is always
> reproducible with this change
> * Most of the code that merged the results of multiple BTF encoders
> into one BTF after CU processing is removed
>
> Motivation behind this change and analysis that led to it are in the
> cover letter to the patch series.
>
> In short, this implementation of BTF encoding makes it reproducible
> without sacrificing the performance gains from parallel
> processing. The speed in terms of wall-clock time is comparable to
> non-reproducible runs on pahole/next [1]. The memory footprint is
> lower with increased number of threads.
>
> pahole/next (12ca112):
>
> Performance counter stats for '/home/theihor/dev/dwarves/build/pahole -J -j24 --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs --btf_encode_detached=/dev/null --lang_exclude=rust /home/theihor/git/kernel.org/bpf-next/kbuild-output/.tmp_vmlinux1' (13 runs):
>
> 50,493,244,369 cycles ( +- 0.26% )
>
> 1.6863 +- 0.0150 seconds time elapsed ( +- 0.89% )
>
> jobs 1, mem 546556 Kb, time 4.53 sec
> jobs 2, mem 599776 Kb, time 2.81 sec
> jobs 4, mem 661756 Kb, time 2.05 sec
> jobs 8, mem 764584 Kb, time 1.58 sec
> jobs 16, mem 844856 Kb, time 1.59 sec
> jobs 32, mem 1047880 Kb, time 1.69 sec
>
> This patchset on top of pahole/next:
>
> Performance counter stats for '/home/theihor/dev/dwarves/build/pahole -J -j24 --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs --btf_encode_detached=/dev/null --lang_exclude=rust /home/theihor/git/kernel.org/bpf-next/kbuild-output/.tmp_vmlinux1' (13 runs):
>
> 31,175,635,417 cycles ( +- 0.22% )
>
> 1.58644 +- 0.00501 seconds time elapsed ( +- 0.32% )
>
> jobs 1, mem 544780 Kb, time 4.47 sec
> jobs 2, mem 553944 Kb, time 4.68 sec
> jobs 4, mem 563352 Kb, time 2.36 sec
> jobs 8, mem 585508 Kb, time 1.73 sec
> jobs 16, mem 635212 Kb, time 1.61 sec
> jobs 32, mem 772752 Kb, time 1.59 sec
>
> [1]: https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?h=next&id=12ca11281912c272f931e836b9160ee827250716
>
> Signed-off-by: Ihor Solodrai <ihor.solodrai@pm.me>
> ---
I think this is a solid idea and a good observation,
but implementation inherits unnecessary complexity from the previous design.
There is no real need to keep single-threaded and multi-threaded modes
separate, instead:
- main thread can serve as a dedicated "collector" thread,
waiting sequentially for CUs with ids ranging from 0 to number of cus;
- configurable number of worker threads can parse DWARF concurrently
and put CU objects to the processing queue;
- the queue size has to be bounded to keep memory consumption within
certain limits (but be careful, a simple bounded queue protected by
semaphore won't do, as the queue might get fully filled with ids
different from expected, in case when first CU takes a very long time
to process and N CUs after it take very short time to process).
[...]
next prev parent reply other threads:[~2024-11-30 0:17 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-28 1:23 [RFC PATCH 0/9] pahole: shared ELF and faster reproducible BTF encoding Ihor Solodrai
2024-11-28 1:23 ` [RFC PATCH 1/9] btf_encoder: simplify function encoding Ihor Solodrai
2024-11-29 8:16 ` Eduard Zingerman
2024-12-02 13:55 ` Jiri Olsa
2024-11-28 1:23 ` [RFC PATCH 2/9] btf_encoder: store,use section-relative addresses in ELF function representation Ihor Solodrai
2024-11-29 9:07 ` Eduard Zingerman
2024-12-02 14:34 ` Alan Maguire
2024-11-28 1:23 ` [RFC PATCH 3/9] btf_encoder: separate elf function, saved function representations Ihor Solodrai
2024-11-29 20:37 ` Eduard Zingerman
2024-12-09 21:19 ` Ihor Solodrai
2024-11-28 1:24 ` [RFC PATCH 4/9] dwarf_loader: introduce pre_load_module hook to conf_load Ihor Solodrai
2024-11-29 21:03 ` Eduard Zingerman
2024-11-28 1:24 ` [RFC PATCH 5/9] btf_encoder: introduce elf_functions struct type Ihor Solodrai
2024-11-29 21:50 ` Eduard Zingerman
2024-11-28 1:24 ` [RFC PATCH 6/9] btf_encoder: collect elf_functions in btf_encoder__pre_load_module Ihor Solodrai
2024-11-29 22:27 ` Eduard Zingerman
2024-11-28 1:24 ` [RFC PATCH 7/9] btf_encoder: switch to shared elf_functions table Ihor Solodrai
2024-11-29 22:35 ` Eduard Zingerman
2024-12-09 23:55 ` Ihor Solodrai
2024-11-28 1:24 ` [RFC PATCH 8/9] btf_encoder: introduce btf_encoding_context Ihor Solodrai
2024-11-29 23:12 ` Eduard Zingerman
2024-11-28 1:24 ` [RFC PATCH 9/9] pahole: faster reproducible BTF encoding Ihor Solodrai
2024-11-30 0:17 ` Eduard Zingerman [this message]
2024-12-02 13:55 ` [RFC PATCH 0/9] pahole: shared ELF and " Jiri Olsa
2024-12-06 18:19 ` Ihor Solodrai
2024-12-06 18:30 ` Arnaldo Carvalho de Melo
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=450a352e713902e4fa091163d283b91786fb8605.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=acme@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dwarves@vger.kernel.org \
--cc=ihor.solodrai@pm.me \
--cc=mykolal@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox