RFC: LD: Changing the size of the delta used when growing merge offset maps
Nick Clifton
nickc@redhat.com
Mon Mar 16 16:35:34 GMT 2026
Hi Guys,
Running the linker under sysprof shows that the append_offsetmap()
function in merge.c is responsible for a large amount of the memory
allocated during a link, and a lot of those allocations are calls to
bfd_realloc(). Since reallocating memory takes time, and represents
an inefficiency it seems to me that we can do better than having a
fixed delta for increasing the size of the offset maps.
So I am proposing the attached patch. It creates a new static
variable called map_delta which is used for the array increments. The
value of map_delta is selected based upon whether
--reduce-memory-overheads or -O have been specified on the command
line. (I am not sure about the use of the -O flag here, but I could
not find a more relevant flag to indicate 'this is a big link').
The results are underwhelming, but still do still make a small amount
of difference. For example linking LLVM's ld.llc executable on my
machine uses 7,121,480 Kb of memory by default and takes around 14.97
seconds. But with the patch applied and adding -O to the link command
line this changes to 7,120,196 Kb and 14.89 seconds. Not a lot I know
but maybe a step in the right direction.
Thoughts / comments ?
Cheers
Nick
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ld.merge.map-delta.patch
Type: text/x-patch
Size: 3013 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260316/68b44d68/attachment.bin>
More information about the Binutils
mailing list