Faster string merging

* use power-of-two hash table
* use better hash function (hashing 32bits at once and with better
  mixing characteristics)
* use input-offset-to-entry maps instead of retaining full input
  contents for lookup time
* don't reread SEC_MERGE section multiple times
* care for cache behaviour for the hot lookup routine

The overall effect is less usage in libz and much faster string merging
itself.  On a debug-info-enabled cc1 the effect at the time of this
writing on the machine I used was going from 14400 perf samples to 9300
perf samples or from 3.7 seconds to 2.4 seconds, i.e. about 33% .
This commit is contained in:
Michael Matz
2022-07-20 17:22:15 +02:00
parent 2e175383bf
commit 1a528d3ef0
5 changed files with 741 additions and 306 deletions

View File

@@ -11361,6 +11361,13 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
contents = flinfo->contents;
}
}
else if (!(o->flags & SEC_RELOC)
&& !bed->elf_backend_write_section
&& o->sec_info_type == SEC_INFO_TYPE_MERGE)
/* A MERGE section that has no relocations doesn't need the
contents anymore, they have been recorded earlier. Except
if the backend has special provisions for writing sections. */
contents = NULL;
else
{
contents = flinfo->contents;