Support parallel builds (enabled by default). #357

Merged
merged 1 commit into from Mar 1, 2016

Conversation

Projects
None yet
3 participants
Member

kyrofa commented Mar 1, 2016

Several plugins within Snapcraft support parallel builds, but Snapcraft currently doesn't take advantage of this and builds them with a single job. This PR resolves LP: #1551417 by adding support for parallel builds, and enabling them by default in the autotools, cmake, and make plugins. It also adds an option to disable parallel builds via the --no-parallel-build option for the case of running in a RAM-limited environment.

snapcraft/main.py
+ -d --debug print debug information while executing (including
+ backtraces)
+ --no-parallel-build use only a single build job per part (defaults to
+ number of CPUs)
@elopio

elopio Mar 1, 2016

Member

This default is confusing. A little. I think I need more words, but I can't find a good way to say it.
Something like: defaults to use the number of CPUs to build parts in parallel.
The problem with this one is that it sounds like you will be building many parts at the same time, instead of building one part at a time.

@kyrofa

kyrofa Mar 1, 2016

Member

Hmm, how about "the default number of jobs per part is equal to the number of CPUs"?

@elopio

elopio Mar 1, 2016

Member

yes, sounds better, IMO.

@@ -110,6 +113,8 @@ def main():
log.configure(log_level=log_level)
+ common.set_enable_parallel_builds(not args['--no-parallel-build'])
+
try:
commands.load(cmd).main(argv=args['ARGS'])
@elopio

elopio Mar 1, 2016

Member

I hate this common and its global variables. Could you delay using it? In here you can pass --no-parallel-build to the build main in argv, which is the only who cares about it. Would that make sense, or just make it worse?

@kyrofa

kyrofa Mar 1, 2016

Member

I agree with you, and I thought about that... but it honestly seemed inconsistent with how we were doing other things. I'm worried that doing that here would fragment the codebase's consistency, which may be worse than disliking how we solve an overall problem. Thoughts?

@elopio

elopio Mar 1, 2016

Member

Sure, that's a great point. Let's just keep thinking about how to get rid of all the globals.

@kyrofa

kyrofa Mar 1, 2016

Member

I'm with you there.

@sergiusens

sergiusens Mar 1, 2016

Collaborator

It would need a rename, but this should live in the yaml module which loads the project (there, that's a new name) and keeps the state of it (state which does not correspond to an individual plugin).

@kyrofa

kyrofa Mar 1, 2016

Member

Yeah that sounds promising. Would we then pass around the project to each command?

@sergiusens

sergiusens Mar 1, 2016

Collaborator

so <command>.main(project) would work in most cases.

I correct myself; the yaml module already handle the plugins as it is part of the whole tree anyways.

This would potentially allow for parallelizing unit test run.

@kyrofa

kyrofa Mar 1, 2016

Member

Yeah, that sounds nice. LP: #1551849.

Member

elopio commented Mar 1, 2016

lgtm. I just hate the common and globals, but I don't have a great solution for that.
If we could reduce the common usage passing arguments at least in a few places, I think that would be better.

What about adding some docs? It would me nice to mention that not all the plugins will use multiple CPUs.

Member

kyrofa commented Mar 1, 2016

@elopio I'm always on board with more docs, though in this case I'm not sure where to put them. This is such a transparent change I don't think it'll really change anyone's life other than making things faster (for some plugins). What did you have in mind?

Member

elopio commented Mar 1, 2016

I thought about docs/snapcraft-usage. That file IMO needs some more content to explain some of the flags.
I also thought about the help itself, maybe in https://github.com/ubuntu-core/snapcraft/pull/357/files#diff-07ab19acf782b5f8bd05c71b8d04f963L46 Mention that by default some build systems will run in parallel.
Any of them sound good to you?

Support parallel builds (enabled by default).
Several plugins within Snapcraft support parallel builds, but
Snapcraft currently doesn't take advantage of this and builds
them with a single job. This commit adds support for parallel
builds, and enables them by default in the autotools, cmake,
and make plugins. It also adds an option to disable parallel
builds via the `--no-parallel-build` option for the case of
running in a RAM-limited environment.

LP: #1551417

Signed-off-by: Kyle Fazzari <kyle@canonical.com>
Member

elopio commented Mar 1, 2016

Perfect. Thanks.

Member

elopio commented Mar 1, 2016

retest this please

kyrofa added a commit that referenced this pull request Mar 1, 2016

Merge pull request #357 from kyrofa/feature/1551417/parallel_builds
Support parallel builds (enabled by default).

@kyrofa kyrofa merged commit 1a62686 into snapcore:master Mar 1, 2016

4 checks passed

Examples tests Success 13 tests run, 0 skipped, 0 failed.
Details
autopkgtest Success No test results found.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.06%) to 94.809%
Details

@kyrofa kyrofa deleted the kyrofa:feature/1551417/parallel_builds branch Mar 1, 2016

smoser pushed a commit to smoser/snapcraft that referenced this pull request Sep 14, 2016

Merge pull request #357 from brendandixon/gh353
Ensure all SSH keys are created before restarting SSH daemon (#353)

kalikiana pushed a commit to kalikiana/snapcraft that referenced this pull request Apr 6, 2017

Merge pull request #357 from kyrofa/feature/1551417/parallel_builds
Support parallel builds (enabled by default).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment