Re: [PATCH v5 4/5] perf script: Add --lazy-load-symbols for lazy symbol loading
From: Alireza Haghdoost
Date: Sun Oct 18 2026 - 12:24:04 EST
Hi Namhyung,
Sorry for the late reply.
On Wed, Oct 7, 2026 at 3:15 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
> I thought we agreed to just use struct symbol and lazy-load the name
> only. With Ian's patch to remove the 'priv' part of symbol and
> hopefully RB-tree node as well, the size of symbol would become
> manageable, I guess.
Ack, in the next revision (v6), I will use struct symbol and load only its
name lazily, as you suggested. I will replace the embedded name with a
union of a name pointer and a file offset. A flag will indicate which
union member is valid. An unresolved lazy symbol will store the file
offset. After perf reads and demangles the name, it will replace the
offset with the name pointer and clear the flag. This removes the
separate index and most of the parity code from v5.
I tested this design on a cgroup profile of a large C++ service. The
loader creates approximately one million symbols. The results are:
time max RSS
perf-tools-next 3.3 s 334 MiB
v5 --lazy-load-symbols 1.4 s 136 MiB
v6 --lazy-load-symbols 1.5 s 154 MiB
All three produce identical output.
The v6 design works with the current RB-tree and does not depend on
Ian's series. Most of the remaining memory difference from v5 comes
from the RB-tree node and one allocation for each symbol. Ian's array
storage can remove the RB-tree node later.
Thanks,
Alireza