From: Denys Dmytriyenko <denis@denix.org>
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 11:12:46 -0400 [thread overview]
Message-ID: <20170614151246.GE28053@denix.org> (raw)
In-Reply-To: <1497447757-30951-3-git-send-email-richard.purdie@linuxfoundation.org>
On Wed, Jun 14, 2017 at 02:42:37PM +0100, Richard Purdie wrote:
> Allow the creation of ipks to happen in parallel, making best use of resources
> on multiprocessor systems.
This is nice! Thanks for looking into the issue of not optimal utilization of
all the available processors and cores.
> 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)
> + 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
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
next prev parent reply other threads:[~2017-06-14 15:12 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 [this message]
2017-06-14 17:43 ` Leonardo Sandoval
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=20170614151246.GE28053@denix.org \
--to=denis@denix.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.