Re: [PATCH v6 3/5] perf symbols: Point to the symbol name instead of embedding it

From: Alireza Haghdoost

Date: Fri Nov 13 2026 - 23:03:06 EST


On Fri, Oct 30, 2026 at 8:34 AM Ian Rogers <irogers@xxxxxxxxxx> wrote:
>
> I think it is a little worse as we'll need 3 bytes of padding. You
> could reduce the padding by moving name to before namelen in the
> struct.

Sorry for the late reply, I held it until v7 was ready. Thanks for the
review. I checked the layout with offsetof() on x86_64.
Before this patch, sizeof(struct symbol) is 48 with name[] at offset
45, and the allocation is sizeof + namelen, so those 3 tail bytes were
already allocated and unused. With this patch, arch_sym is at 44, the
name pointer at 48 and sizeof is 56, and an eager name is stored right
after the struct. That is 8 bytes more per eager symbol, not 11.

Moving name before namelen keeps sizeof at 56, because the struct then
ends with namelen, flags and arch_sym at 48..52 and pads to 56. The 3
bytes would only help if the eager name were stored at
offsetof(arch_sym) + 1 and the allocation sized from that, with
symbol__delete() changed to match. Lazy symbols stay at sizeof either
way. I would rather keep this patch simple, so v7 leaves the order as
is.

> This change makes sense to me. I'm wondering if any other things
> should be cleaned up with this change? For example, namelen is only
> referenced in about 8 places and we may be able to replace it with
> `strlen(name)`.

Yes. namelen is set in symbol.c and read for column widths in hist.c,
in srcline.c and in data-convert-json.c. Dropping it saves 2 bytes, but
not sizeof on its own. I can send that as a follow-up after this series.

Thanks,
Alireza