On Fri, 2024-12-13 at 22:37 +0000, Ihor Solodrai wrote: > Introduce a static struct holding global data necessary for BTF > encoding: elf_functions tables and btf_encoder structs. > > The context has init()/exit() interface that should be used to > indicate when BTF encoding work has started and ended. > > I considered freeing everything contained in the context exclusively > on exit(), however it turns out this unnecessarily increases max > RSS. Probably because the work done in btf_encoder__encode() requires > relatively more memory, and if encoders and tables are freed earlier, > that space is reused. > > Compare: > -j4: Maximum resident set size (kbytes): 868484 > -j8: Maximum resident set size (kbytes): 1003040 > -j16: Maximum resident set size (kbytes): 1039416 > -j32: Maximum resident set size (kbytes): 1145312 > vs > -j4: Maximum resident set size (kbytes): 972692 > -j8: Maximum resident set size (kbytes): 1043184 > -j16: Maximum resident set size (kbytes): 1081156 > -j32: Maximum resident set size (kbytes): 1218184 > > Signed-off-by: Ihor Solodrai <ihor.solodrai@xxxxx> > --- After patch #10 "dwarf_loader: multithreading with a job/worker model" from this series I do not understand why this patch is necessary. After patch #10 there is only one BTF encoder, thus: - there is no need to track btf_encoder_list; - elf_functions_list can now be a part of the encoder; - it should be possible to forgo global variable for encoder and pass it as a parameter for each btf_encoder__* func. So it seems that this patch should be dropped and replaced by one that follows patch #10 and applies the above simplifications. Wdyt? [...]