public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com
Subject: [committed] Use actual die count in read_multifile mode
Date: Tue, 01 Jan 2019 00:00:00 -0000	[thread overview]
Message-ID: <20191125144726.GA7139@delia> (raw)

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

                 reply	other threads:[~2019-11-25 14:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191125144726.GA7139@delia \
    --to=tdevries@suse.de \
    --cc=dwz@sourceware.org \
    --cc=jakub@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).