Merge lp:~jtv/maas/parallel-lint into lp:~maas-committers/maas/trunk

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: 3149
Proposed branch: lp:~jtv/maas/parallel-lint
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 33 lines (+11/-3)
1 file modified
Makefile (+11/-3)
To merge this branch: bzr merge lp:~jtv/maas/parallel-lint
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+236660@code.launchpad.net

Commit message

Run multiple lint checks in parallel. They were getting really annoyingly slow.

Description of the change

This may still need tuning, and the output from multiple commands will be interleaved if there's lint in multiple files. We can address that with GNU parallel it it turns out to be a real problem; it has a --keep-order option.

On my main development system, this consistently made “make lint” complete in half its previous time. Still feels slow, but...

Jeroen

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

You're crazy and a little bit awesome too.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2014-09-30 09:28:45 +0000
3+++ Makefile 2014-10-01 07:34:47 +0000
4@@ -133,18 +133,26 @@
5 @find $(sources) -type f \
6 -print0 | xargs -r0 $(pocketlint) --max-length=120
7
8+# Python lint checks are time-intensive, so we run them in parallel. It may
9+# make things matters worse if the files need to be read from disk, though, so
10+# this may need more tuning.
11+# The -n50 -P4 setting roughly doubled speed on a high-end system with SSD and
12+# all the files in cache.
13 lint-py: sources = $(wildcard *.py contrib/*.py) src templates twisted utilities etc
14 lint-py: bin/flake8
15- @find $(sources) -name '*.py' ! -path '*/migrations/*' \
16- -print0 | xargs -r0 bin/flake8 --ignore=E123 --config=/dev/null
17+ @find $(sources) -name '*.py' ! -path '*/migrations/*' -print0 \
18+ | xargs -r0 -n50 -P4 bin/flake8 --ignore=E123 --config=/dev/null
19 @./utilities/check-maaslog-exception
20
21 lint-doc:
22 @./utilities/doc-lint
23
24+# JavaScript lint is checked in parallel for speed. The -n20 -P4 seetting
25+# worked well on a multicore SSD machine with the files cached, roughly
26+# doubling the speed, but it may need tuning for slower systems or cold caches.
27 lint-js: sources = src/maasserver/static/js
28 lint-js:
29- @find $(sources) -type f -print0 '(' -name '*.html' -o -name '*.js' ')' | xargs -r0 $(pocketlint)
30+ @find $(sources) -type f -print0 '(' -name '*.html' -o -name '*.js' ')' | xargs -r0 -n20 -P4 $(pocketlint)
31
32 # Apply automated formatting to all Python files.
33 format: sources = $(wildcard *.py contrib/*.py) src templates twisted utilities etc