.gdb_index prod perf regression: Estimate size of psyms_seen
authorPedro Alves <palves@redhat.com>
Mon, 12 Jun 2017 01:40:18 +0000 (02:40 +0100)
committerPedro Alves <palves@redhat.com>
Mon, 12 Jun 2017 16:06:25 +0000 (17:06 +0100)
commite8f8bcb35f22965c8e4309c4aa4227241c485fe7
treed7f113ea968a514feb5327c27a76f393e6f41a11
parent70a1152bee7cb959ab0c6c13bada03190125022f
.gdb_index prod perf regression: Estimate size of psyms_seen

Using the same test as the previous patch, perf shows GDB spending
over 7% in "free".  A substantial number of those calls comes from
insertions in the psyms_seen unordered_set causing lots of rehashing
and recreating buckets.  Fix this by computing an estimate of the size
of the set upfront.

Using the same test as in the previous patch, against the same gdb
inferior, timing improves ~8% further:

  ~6.5s => ~6.0s (average of 5 runs).

gdb/ChangeLog:
2017-06-12  Pedro Alves  <palves@redhat.com>

* dwarf2read.c (recursively_count_psymbols): New function.
(write_psymtabs_to_index): Call it to compute number of psyms and
pass estimate size of psyms_seen to unordered_set's ctor.
gdb/ChangeLog
gdb/dwarf2read.c