Problem/Motivation

phpcs has a --parallel option that significantly speeds up test runs by using multiple PHP processes. Compare:

$ time vendor/bin/phpcs -ps --standard=core/phpcs.xml.dist
............................................................    60 / 11909 (1%)
...
.............................                                11909 / 11909 (100%)


Time: 3 mins, 26.21 secs; Memory: 208MB


real	3m26.606s
user	3m21.222s
sys	0m3.417s

vs

$ time vendor/bin/phpcs -ps --standard=core/phpcs.xml.dist --parallel=$(nproc)
........ 8 / 8 (100%)


Time: 1 mins, 24.88 secs; Memory: 6MB


real	1m24.992s
user	6m56.904s
sys	0m6.074s

Steps to reproduce

Proposed resolution

Add --parallel=$(nproc) to the lines that invoke phpcs.

Remaining tasks

Check that the script still fails correctly when coding standards are not met.

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#3 3312089-3.patch1.27 KBlongwave

Comments

longwave created an issue. See original summary.

wim leers’s picture

longwave’s picture

Status: Active » Needs review
StatusFileSize
new1.27 KB

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Since the 10.1 tests pass assuming this is good.

  • catch committed 28ce5b7 on 10.0.x
    Issue #3312089 by longwave: Run phpcs in parallel in commit-code-check....
  • catch committed a531dfd on 10.1.x
    Issue #3312089 by longwave: Run phpcs in parallel in commit-code-check....
  • catch committed 3e45d44 on 9.5.x
    Issue #3312089 by longwave: Run phpcs in parallel in commit-code-check....
catch’s picture

Version: 10.1.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 10.1.x, cherry-picked to 10.0.x and 9.5.x, thanks!

wim leers’s picture

… and this just shaved some valuable time off of each DrupalCI run! 🤩👏 Thanks, @longwave & @smustgrave!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

xjm’s picture

This introduced #3407360: Commit check script: nproc does not exist on Darwin. It's not all that serious because it does not prevent the script from completing, but it does mean Macs still run the script without parallelization and throws a warning that might confuse people (like me).