[musl] Re: realloci(): A realloc() variant that works in-place
Thiago Macieira
thiago@macieira.org
Tue Nov 4 17:24:25 GMT 2025
On Tuesday, 4 November 2025 02:31:38 Pacific Standard Time Szabolcs Nagy wrote:
> is there an analysis with actual numbers so one
> can see the tradeoffs instead of speculating?
> we know that users think a new api would be
> useful, but some evidence is needed.
I'm modifying Qt to insert a "reallocateInPlace" call where it would
eventually be, with an out-of-line function that currently simply fails all
the time because I neither have xallocx() nor realloci(). In spite of that,
disassembly shows the compiler is not inlining it even in LTO mode.
In fact, just by looking at the places where it is being called from reveals
the data types that could benefit from this. And some that could benefit from
realloc() in the first place, if only we could declare & detect the type in
question bitwise trivially relocatable.
A quick check with the qtdiag application shows it did get called:
Thread 1 "qtdiag" hit Breakpoint 1, QArrayData::reallocateInPlace
(data=0x5555555bdc30, objectSize=48, alignment=16, capacity=3,
option=QArrayData::Grow)
Thread 1 "qtdiag" hit Breakpoint 1, QArrayData::reallocateInPlace
(data=0x5555555c8920, objectSize=48, alignment=16, capacity=6,
option=QArrayData::Grow)
Thread 1 "qtdiag" hit Breakpoint 1, QArrayData::reallocateInPlace
(data=0x5555555ccf50, objectSize=48, alignment=16, capacity=11,
option=QArrayData::Grow)
Thread 1 "qtdiag" hit Breakpoint 1, QArrayData::reallocateInPlace
(data=0x5555555cd600, objectSize=48, alignment=16, capacity=22,
option=QArrayData::Grow)
I'll have more information for a more complex application once I finish
rebuilding everything.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Principal Engineer - Intel Data Center - Platform & Sys. Eng.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 870 bytes
Desc: This is a digitally signed message part.
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20251104/404c68c4/attachment.sig>
More information about the Libc-alpha
mailing list