Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
To: Richard Purdie <richard.purdie@linuxfoundation.org>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH 3/3] package_ipk: Parallelise ipk creation
Date: Wed, 14 Jun 2017 12:43:58 -0500	[thread overview]
Message-ID: <1497462238.29576.11.camel@linux.intel.com> (raw)
In-Reply-To: <1497447757-30951-3-git-send-email-richard.purdie@linuxfoundation.org>

On Wed, 2017-06-14 at 14:42 +0100, Richard Purdie wrote:
> Allow the creation of ipks to happen in parallel, making best use of resources
> on multiprocessor systems.
> 
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  meta/classes/package_ipk.bbclass | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass
> index d2ce3b3..282d212 100644
> --- a/meta/classes/package_ipk.bbclass
> +++ b/meta/classes/package_ipk.bbclass
> @@ -17,6 +17,8 @@ OPKG_ARGS += "${@['', '--add-exclude ' + ' --add-exclude '.join((d.getVar('PACKA
>  OPKGLIBDIR = "${localstatedir}/lib"
>  
>  python do_package_ipk () {
> +    from multiprocessing import Process
> +
>      oldcwd = os.getcwd()
>  
>      workdir = d.getVar('WORKDIR')
> @@ -37,11 +39,24 @@ python do_package_ipk () {
>      if os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"), os.R_OK):
>          os.unlink(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"))
>  
> -    for pkg in packages.split():
> -        ipk_write_pkg(pkg, d)


this part looks quite similar as the 2/3, perhaps a single function
inside package.bbclass?

> +    max_process = int(d.getVar("BB_NUMBER_THREADS") or os.cpu_count() or 1)
> +    launched = []
> +    pkgs = packages.split()
> +    while pkgs:
> +        if len(launched) < max_process:
> +            p = Process(target=ipk_write_pkg, args=(pkgs.pop(), d))
> +            p.start()
> +            launched.append(p)
> +        for q in launched:
> +            # The finished processes are joined when calling is_alive()
> +            if not q.is_alive():
> +                launched.remove(q)
> +    for p in launched:
> +        p.join()
>  
>      os.chdir(oldcwd)
>  }
> +do_package_ipk[vardepsexclude] = "BB_NUMBER_THREADS"
>  
>  def ipk_write_pkg(pkg, d):
>      import re, copy
> -- 
> 2.7.4
> 




  parent reply	other threads:[~2017-06-14 17:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-14 13:42 [PATCH 1/3] pseudo: Handle too many files deadlock Richard Purdie
2017-06-14 13:42 ` [PATCH 2/3] package_deb: Enable multithreaded package creation Richard Purdie
2017-06-14 13:42 ` [PATCH 3/3] package_ipk: Parallelise ipk creation Richard Purdie
2017-06-14 15:12   ` Denys Dmytriyenko
2017-06-14 17:43   ` Leonardo Sandoval [this message]
2017-06-16  2:28   ` Khem Raj
2017-06-16  9:01     ` Richard Purdie
2017-06-14 13:51 ` [PATCH 1/3] pseudo: Handle too many files deadlock Gary Thomas
2017-06-16  9:03   ` Richard Purdie
2017-06-14 14:01 ` ✗ patchtest: failure for "pseudo: Handle too many files ..." and 2 more Patchwork

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=1497462238.29576.11.camel@linux.intel.com \
    --to=leonardo.sandoval.gonzalez@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=richard.purdie@linuxfoundation.org \
    /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