[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[committed] Use actual die count in read_multifile mode



Hi,

With a debug patch added, we can see the following trace:
...
$ cp hello 1; cp 1 2; dwz -m 3 1 2 --devel-trace
Compressing 1
Used estimated number of dies of 72 for off_htab allocation
Write-multifile 1
Compressing 2
Used estimated number of dies of 72 for off_htab allocation
Write-multifile 2
Optimize-multifile
Read-multifile
Used estimated number of dies of 53 for off_htab allocation
Compressing 1 in finalize-multifile mode
Using die count 73 for off_htab allocation
Compressing 2 in finalize-multifile mode
Using die count 73 for off_htab allocation
...

However, in read-multifile mode, there's no need to estimate the number
of DIEs, since we write the file during optimize-multifile mode and can keep
track of the number of DIEs.

So, in read-multifile, use actual DIE count, rather than an estimate
for off_htab allocation.

In combination with the same debug patch, this gives us:
...
 $ cp hello 1; cp 1 2; dwz -m 3 1 2 --devel-trace
 Compressing 1
 Used estimated number of dies of 72 for off_htab allocation
 Write-multifile 1
 Compressing 2
 Used estimated number of dies of 72 for off_htab allocation
 Write-multifile 2
 Optimize-multifile
 Read-multifile
-Used estimated number of dies of 53 for off_htab allocation
+Using die count 72 for off_htab allocation
 Compressing 1 in finalize-multifile mode
 Using die count 73 for off_htab allocation
 Compressing 2 in finalize-multifile mode
 Using die count 73 for off_htab allocation
...

Committed to trunk.

Thanks,
- Tom

Use actual die count in read_multifile mode

2019-11-25  Tom de Vries  <tdevries@suse.de>

	* dwz.c (optimize_multifile, read_multifile): Add die_count parameter.
	(main): Pass multifile_die_count to optimize_multifile and
	read_multifile.

---
 dwz.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/dwz.c b/dwz.c
index 26ac55b..a4073c3 100644
--- a/dwz.c
+++ b/dwz.c
@@ -12297,7 +12297,7 @@ static unsigned int *strp_tail_off_list;
 /* Process temporary .debug_* files, see what can be beneficially shared
    and write a new ET_REL file, containing the shared .debug_* sections.  */
 static int
-optimize_multifile (void)
+optimize_multifile (unsigned int *die_count)
 {
   DSO dsobuf, *dso;
   int fd = -1;
@@ -12478,7 +12478,7 @@ optimize_multifile (void)
 	  strp_tail_off_list = finalize_strp (true);
 
 	  write_abbrev ();
-	  write_info (NULL);
+	  write_info (die_count);
 	  write_gdb_index ();
 	  if (write_multifile_line ())
 	    goto fail;
@@ -12682,7 +12682,7 @@ optimize_multifile (void)
    by optimize_multifile into data structures for fi_multifile
    phase.  */
 static DSO *
-read_multifile (int fd)
+read_multifile (int fd, unsigned int die_count)
 {
   DSO *dso, *volatile ret;
   unsigned int i;
@@ -12715,7 +12715,7 @@ read_multifile (int fd)
       obstack_init (&ob);
       obstack_init (&ob2);
 
-      if (read_dwarf (dso, false, NULL))
+      if (read_dwarf (dso, false, &die_count))
 	goto fail;
 
       if (debug_sections[DEBUG_STR].size)
@@ -13108,11 +13108,12 @@ main (int argc, char *argv[])
 	}
       if (multifile)
 	{
-	  int multi_fd = optimize_multifile ();
+	  unsigned int multifile_die_count = 0;
+	  int multi_fd = optimize_multifile (&multifile_die_count);
 	  DSO *dso;
 	  if (multi_fd == -1)
 	    return 1;
-	  dso = read_multifile (multi_fd);
+	  dso = read_multifile (multi_fd, multifile_die_count);
 	  if (dso == NULL)
 	    ret = 1;
 	  else