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] Handle dwz -l0 more efficiently
Date: Tue, 01 Jan 2019 00:00:00 -0000	[thread overview]
Message-ID: <20191113114225.GA19002@delia> (raw)

Hi,

If dwz is invoked with -l0, the dwz function is initially called without
low-mem mode set, while it's certain that the call will run into the
low-mem-die-limit:
...
$ dwz -l0 1 --devel-trace
Compressing 1
Hit low-mem die-limit
Compressing 1 in low-mem mode
...

Fix this by skipping the initial dwz call:
...
$ dwz -l0 1 --devel-trace
Compressing 1 in low-mem mode
...

Committed to trunk.

Thanks,
- Tom

Handle dwz -l0 more efficiently

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

	* dwz.c (main): Only try dwz without MULTIFILE_MODE_LOW_MEM if
	low_mem_die_limit != 0.
	* testsuite/dwz.tests/low-mem-die-limit-0.sh: New test.
	* testsuite/dwz.tests/two-files-low-mem-die-limit-0.sh: New test.

---
 dwz.c                                                | 12 ++++++++----
 testsuite/dwz.tests/low-mem-die-limit-0.sh           | 13 +++++++++++++
 testsuite/dwz.tests/two-files-low-mem-die-limit-0.sh | 14 ++++++++++++++
 3 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/dwz.c b/dwz.c
index e990693..9f37fd0 100644
--- a/dwz.c
+++ b/dwz.c
@@ -12756,8 +12756,10 @@ main (int argc, char *argv[])
 	  error (0, 0, "Too few files for multifile optimization");
 	  multifile = NULL;
 	}
-      ret = dwz (optind == argc ? "a.out" : argv[optind], outfile,
-		 &res, NULL, NULL);
+      ret = (low_mem_die_limit == 0
+	     ? 2
+	     : dwz (optind == argc ? "a.out" : argv[optind], outfile,
+		    &res, NULL, NULL));
       if (ret == 2)
 	{
 	  multifile_mode = MULTIFILE_MODE_LOW_MEM;
@@ -12795,8 +12797,10 @@ main (int argc, char *argv[])
 	}
       for (i = optind; i < argc; i++)
 	{
-	  int thisret = dwz (argv[i], NULL, &resa[i - optind],
-			     hardlinks ? resa : NULL, &argv[optind]);
+	  int thisret = (low_mem_die_limit == 0
+			 ? 2
+			 : dwz (argv[i], NULL, &resa[i - optind],
+				hardlinks ? resa : NULL, &argv[optind]));
 	  if (thisret == 2)
 	    {
 	      multifile_mode = MULTIFILE_MODE_LOW_MEM;
diff --git a/testsuite/dwz.tests/low-mem-die-limit-0.sh b/testsuite/dwz.tests/low-mem-die-limit-0.sh
new file mode 100644
index 0000000..7105431
--- /dev/null
+++ b/testsuite/dwz.tests/low-mem-die-limit-0.sh
@@ -0,0 +1,13 @@
+cp $execs/hello 1
+
+$execs/dwz-for-test \
+    -l0 \
+    --devel-trace \
+    1 \
+    2> dwz.err
+
+if grep -q "Compressing 1$" dwz.err; then
+    exit 1
+fi
+
+rm -f 1 dwz.err
diff --git a/testsuite/dwz.tests/two-files-low-mem-die-limit-0.sh b/testsuite/dwz.tests/two-files-low-mem-die-limit-0.sh
new file mode 100644
index 0000000..7f1e174
--- /dev/null
+++ b/testsuite/dwz.tests/two-files-low-mem-die-limit-0.sh
@@ -0,0 +1,14 @@
+cp $execs/hello 1
+cp 1 2
+
+$execs/dwz-for-test \
+    -l0 \
+    --devel-trace \
+    1 2 \
+    2> dwz.err
+
+if egrep -q "Compressing (1|2)$" dwz.err; then
+    exit 1
+fi
+
+rm -f 1 2 dwz.err

                 reply	other threads:[~2019-11-13 11:42 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=20191113114225.GA19002@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).