Re: [PATCH v2 07/18] perf symbol: Switch backing storage from rbtree to struct symbols array
From: Alireza Haghdoost
Date: Fri Oct 30 2026 - 09:12:49 EST
On Tue, Oct 27, 2026 at 4:15 PM Ian Rogers <irogers@xxxxxxxxxx> wrote:
> + if (symbols->sorted && symbols->cnt > 0 &&
> + !symbol__less_or_equal(symbols->symbols[symbols->cnt - 1], sym))
> + symbols->sorted = false;
Just want to call out that in here, every out-of-order insert clears
sorted, and the next lookup qsort()s the whole array.
This is fixed in 9/18 I think but moving the sorted insert into
this patch make it more clean.
Some behaviour notes:
- Symbols with the same start are now ordered by end instead of by
insertion order. That can change which alias
symbols__fixup_duplicate() keeps.
- The order of full ties now depends on qsort() being stable.
Patch 09/18 replaces it with a stable sort, but still falls
back to qsort() if the merge buffer can't be allocated.
- On libc.so.6 I see 62 differing @plt-name lines compared with the
previous patch, for example __GI_memcpy@plt, although both sides
still have 55 @plt symbols. My guess is that this comes from
get_ifunc_name(): for an unnamed R_X86_64_IRELATIVE relocation it
resolves the addend with dso__find_symbol_nocache(), and libc has
several IFUNC names or aliases at the same address. The old rbtree
and the new array do not necessarily return the same alias there,
because same-start symbols are now ordered by end and full ties go
through qsort(). The PLT address and count stay the same, but the
displayed name changes. Was that intended?
Thanks,
Alireza