public inbox for debugedit@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Kalev Lember <klember@redhat.com>, debugedit@sourceware.org
Subject: Re: [PATCH] find-debuginfo: Pass -j down to dwz
Date: Thu, 26 Jan 2023 15:34:12 +0100	[thread overview]
Message-ID: <3fa74c6c1f99765430b0e041c050d47b0a993aec.camel@klomp.org> (raw)
In-Reply-To: <20230119160318.3868439-1-klember@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1370 bytes --]

Hi Kalev,

On Thu, 2023-01-19 at 17:03 +0100, Kalev Lember wrote:
> Now that dwz 0.15 supports parallel jobs, add a way to control it from
> here. find-debuginfo already has a -j parameter so we can just extend it
> and pass the value down to dwz as well.
> 
> This should fix building large packages on memory constrained builders,
> such as webkitgtk on s390x in Fedora koji build system, where we can now
> use the -j option to tune down parallelism to avoid running out of
> memory during dwz run.

Aha, you want to reduce the default parallelism (processors / 2)?

> diff --git a/scripts/find-debuginfo.in b/scripts/find-debuginfo.in
> index b07a52f..8cc1bfd 100755
> --- a/scripts/find-debuginfo.in
> +++ b/scripts/find-debuginfo.in
> @@ -585,7 +585,7 @@ if $run_dwz \
>        dwz_multifile_suffix=".${dwz_multifile_idx}"
>      done
>      dwz_multifile_name="${dwz_multifile_name}${dwz_multifile_suffix}"
> -    dwz_opts="-h -q -r"
> +    dwz_opts="-h -q -r -j ${n_jobs}"
>      [ ${#dwz_files[@]} -gt 1 ] && [ "$dwz_single_file_mode" = "false" ] \
>        && dwz_opts="${dwz_opts} -m .dwz/${dwz_multifile_name}"
>      mkdir -p "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz"

I agree with Panu that a configure check would be nice to make sure the
installed dwz does support -j. Would the attached patch work for you?

Thanks,

Mark

[-- Attachment #2: dwz_j.patch --]
[-- Type: text/x-patch, Size: 2047 bytes --]

diff --git a/Makefile.am b/Makefile.am
index 2060b96..4a5092d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,7 +33,8 @@ CLEANFILES = $(bin_SCRIPTS)
 # Some standard substitutions for scripts
 do_subst = ($(SED) -e 's,[@]PACKAGE[@],$(PACKAGE),g' \
 		   -e 's,[@]VERSION[@],$(VERSION),g' \
-		   -e 's,[@]READELF[@],$(READELF),g')
+		   -e 's,[@]READELF[@],$(READELF),g' \
+		   -e 's,[@]DWZ_J[@],$(DWZ_J),g')
 
 find-debuginfo: $(top_srcdir)/scripts/find-debuginfo.in Makefile
 	$(do_subst) < "$(top_srcdir)/scripts/$@.in" > "$@"
diff --git a/configure.ac b/configure.ac
index 6a53365..f2d1571 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,6 +47,27 @@ AC_CHECK_TOOL([LD], [ld])
 AC_CHECK_TOOL([READELF], [readelf])
 AM_MISSING_PROG(HELP2MAN, help2man)
 
+# Whether dwz support -j.
+# Make sure to compile something with -g.
+# Run dwz on it with -j1.
+DWZ_J=""
+AC_CHECK_PROG([DWZ], [dwz], [dwz])
+if test "x$DWZ" = "xdwz"; then
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$save_CFLAGS -g"
+  AC_CACHE_CHECK([whether the dwz support -j], ac_cv_dwz_j, [dnl
+    AC_LINK_IFELSE([AC_LANG_PROGRAM()],[dnl
+      ac_cv_dwz_j=yes; ${DWZ} -j1 conftest$EXEEXT 2>/dev/null || ac_cv_dwz_j=no],
+      AC_MSG_FAILURE([unexpected compile failure]))])
+  if test "x$ac_cv_dwz_j" = "xyes"; then
+    DWZ_J="-j"
+  fi
+  CFLAGS="$save_CFLAGS"
+else
+  AC_MSG_WARN([dwz not installed])
+fi
+AC_SUBST([DWZ_J])
+
 # Only really an issue on 32bit platforms. Makes sure we'll get large off_t.
 AC_SYS_LARGEFILE
 
diff --git a/scripts/find-debuginfo.in b/scripts/find-debuginfo.in
index b07a52f..8090c84 100755
--- a/scripts/find-debuginfo.in
+++ b/scripts/find-debuginfo.in
@@ -586,6 +586,7 @@ if $run_dwz \
     done
     dwz_multifile_name="${dwz_multifile_name}${dwz_multifile_suffix}"
     dwz_opts="-h -q -r"
+    [ -n "@DWZ_J@" ] && dwz_opts="${dwz_opts} -j ${n_jobs}"
     [ ${#dwz_files[@]} -gt 1 ] && [ "$dwz_single_file_mode" = "false" ] \
       && dwz_opts="${dwz_opts} -m .dwz/${dwz_multifile_name}"
     mkdir -p "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz"

  parent reply	other threads:[~2023-01-26 14:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-19 16:03 Kalev Lember
2023-01-20  8:39 ` Panu Matilainen
2023-01-20 10:27   ` Kalev Lember
2023-01-20 11:27     ` Panu Matilainen
2023-01-26 14:34 ` Mark Wielaard [this message]
2023-01-26 15:57   ` Kalev Lember
2023-01-26 23:14     ` Mark Wielaard
2023-01-27 17:37       ` Mark Wielaard
2023-01-28  1:07         ` Kalev Lember

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=3fa74c6c1f99765430b0e041c050d47b0a993aec.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=debugedit@sourceware.org \
    --cc=klember@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).