This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gold][patch] Reduce heap usage for string merge sections


>> Good idea -- do you have a suggestion for estimating that? I could
>> just divide the size of the section by a presumed average string
>> length. The average string length might depend heavily on the source
>> language and what the section is, though. (Although I suppose a
>> conservative estimate, based on a large average string length, is
>> better than doing nothing.)
>
> The cost of overestimating is not that high, so I would just assume that
> each string has, say, 8 characters.

It turns out that the cost is actually quite substantial. For
.debug_str, if the average string is, say 64 bytes, an estimate based
on an average of 8 would reserve 8 times as much memory as we actually
need. On my benchmark, adding the reserve call made gold use about 3
times as much memory for the Merged_string structures.

Instead of using a fixed average string size, I could sample the first
N bytes of the section to come up with the estimate. How does that
sound?

-cary


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]