Dwp tool heap usage, reducing the memory foot-print.

Cary Coutant ccoutant@gmail.com
Wed Nov 18 01:01:00 GMT 2015


> We are allocating a heap buffer to copy the stringpool buffer and then
> writing that to the output file.  Why not just do it directly?  I see
> this is done in two places, one to write the debug string table and
> another to write the section string table.  These allocations are
> pretty significant (each ~20% the size of the input files combined).
>
> Looking into stringpool functions, I see there is one to write
> directly to a file
> template<typename Stringpool_char>
> void Stringpool_template<Stringpool_char>::write(Output_file* of, off_t offset)
>
> but that needs an Output_file object and we dont have one. What is the
> downside of eliminating this buffer?

I agree, this would make a significant improvement.

Unfortunately, Stringpool_template::write() assumes the output file is
memory mapped, and calls write_to_buffer() to write directly to the
mapped region. Dwp doesn't mmap the output file, so that won't work.

Probably the best approach would be to add a
Stringpool_template::write_to_file() that works like
write_to_buffer(), but instead writes the strings into a small
fixed-size buffer, flushing that buffer out to the file with
::fwrite() as it fills up (and at the end).

-cary



More information about the Binutils mailing list