|
|
Message-ID: <6582849.RfpFWEtPUA@tjmaciei-mobl5>
Date: Wed, 05 Nov 2025 09:38:42 -0800
From: Thiago Macieira <thiago@...ieira.org>
To: Rich Felker <dalias@...c.org>, Alejandro Colomar <alx@...nel.org>
Cc: Demi Marie Obenour <demiobenour@...il.com>, musl@...ts.openwall.com,
The 8472 <the8472.rs@...inite-source.de>, Florian Weimer <fw@...eb.enyo.de>,
libc-alpha@...rceware.org, Arthur O'Dwyer <arthur.j.odwyer@...il.com>,
Jonathan Wakely <jwakely@...hat.com>
Subject: Re: Re: realloci(): A realloc() variant that works in-place
On Wednesday, 5 November 2025 03:24:14 Pacific Standard Time Alejandro Colomar
wrote:
> Agree. Before adding realloci(), I'd like to see numbers. An
> interesting thing to do would be to see some application that uses
> realloc(3) currently, and check how often realloc(3) doesn't move the
> object. (To test that without UB, one needs to do the trick with
> uintptr_t.)
I can give you some numbers for realloc() success, with the understanding that
they are NOT AT ALL the cases where realloci() would be used. I can't emit a
realloc() call that MAY relocate an an array of objects, if the objects don't
allow relocating. That would crash the application on the first time realloc()
did relocate. So I can only do it for the cases where the implementation would
keep using realloc() in the future.
The only way to test how often realloci() would succeed is to have realloci().
Anyway, my test is running qtcreator. Remember that it called the placeholder
function that would call realloci() 119 times just for running --help.
It also called QArrayData::reallocateUnaligned() with objectSize > 4 a total
of 1577 times, in 115 of which realloc() returned the same pointer (7.3%). In
fact, a quick glimpse of the gdb output shows that the same pointer succeed in
growing more than once in a row: I see a pointer at least 4x twice in a row,
with an increased capacity parameter, suggesting that it's the same array.
In the full run (without --help), realloc() extended in place 1045 out of
10088 calls, increasing to 10.3% extension success rate.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Principal Engineer - Intel Data Center - Platform & Sys. Eng.
Download attachment "signature.asc" of type "application/pgp-signature" (871 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.