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


I tried a few different formulas for estimating and refining the
estimate, and got the best results with an initial estimate of (len /
64 + 5) and a refined estimate of (len / avg_so_far + 5). The overhead
was down to just over 1% (20% for the .rodata sections, and about 1%
for .debug_str sections), with total run time a bit better than with
no initial reserve.

That still didn't beat the simplest approach: count the strings in
advance and reserve the exact amount. That cut overhead to 0%
(obviously), and cut total run time by 80 seconds or so.

Here's a patch that simply counts the strings. I also added an extra
line of --stats output that helps figure the average string size.

Tested on x86_64.

-cary

        * merge.cc (Output_merge_string::do_add_input_section): Count strings
        to reserve space in merged_strings vector. Keep total input size
        for stats.
        (Output_merge_string::do_print_merge_stats): Print total input size.
        * merge.h (Output_merge_string): Add input_size_ field.

Attachment: gold-merge-count-patch.txt
Description: Text document


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