This is the mail archive of the
mailing list for the binutils project.
Re: Dwp tool heap usage, reducing the memory foot-print.
- From: Cary Coutant <ccoutant at gmail dot com>
- To: Sriraman Tallam <tmsriram at google dot com>
- Cc: binutils <binutils at sourceware dot org>, Sterling Augustine <saugustine at google dot com>, Than McIntosh <thanm at google dot com>, David Li <davidxl at google dot com>
- Date: Tue, 17 Nov 2015 17:00:58 -0800
- Subject: Re: Dwp tool heap usage, reducing the memory foot-print.
- Authentication-results: sourceware.org; auth=none
- References: <CAAs8HmykAs2z=-OWKpW4NU_z=Eu=Gh1Q=n8_XnJy9aefae9SxQ at mail dot gmail dot com>
> 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).