public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
* [committed] Handle dwz -l0 more efficiently
@ 2019-01-01  0:00 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2019-01-01  0:00 UTC (permalink / raw)
  To: dwz, jakub

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-13 11:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-01  0:00 [committed] Handle dwz -l0 more efficiently Tom de Vries

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).