Skip to content

Commit

Permalink
project.py: paralelize west update
Browse files Browse the repository at this point in the history
The projects from manifests were updated one by one.
The parallel aproach has potential to fully utilize
CPU and network connection to speed up the update.

Signed-off-by: Robert Gałat <[email protected]>
  • Loading branch information
RobertGalatNordic committed Jun 11, 2024
1 parent cf18ce8 commit 6c1fb2e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
'pykwalify',
'setuptools',
'packaging',
'joblib'
],
python_requires='>=3.8',
entry_points={'console_scripts': ('west = west.app.main:main',)},
Expand Down
16 changes: 11 additions & 5 deletions src/west/app/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'''West project commands'''

import argparse
from joblib import Parallel, delayed
from functools import partial
import logging
import os
Expand Down Expand Up @@ -1018,18 +1019,21 @@ def update_all(self):
import_flags=ImportFlag.FORCE_PROJECTS)

failed = []
for project in self.manifest.projects:

def project_update(project):
if (isinstance(project, ManifestProject) or
project.name in self.updated):
continue
return
try:
if not self.project_is_active(project):
self.dbg(f'{project.name}: skipping inactive project')
continue
return
self.update(project)
self.updated.add(project.name)
except subprocess.CalledProcessError:
failed.append(project)

Parallel(n_jobs=-1)(delayed(project_update)(project) for project in self.manifest.projects)
self._handle_failed(self.args, failed)

def update_importer(self, project, path):
Expand Down Expand Up @@ -1090,13 +1094,15 @@ def update_some(self):
projects = self._projects(self.args.projects)

failed = []
for project in projects:
def project_update_some(project):
if isinstance(project, ManifestProject):
continue
return
try:
self.update(project)
except subprocess.CalledProcessError:
failed.append(project)

Parallel(n_jobs=-1)(delayed(project_update_some)(project) for project in self.manifest.projects)
self._handle_failed(self.args, failed)

def toplevel_projects(self):
Expand Down

0 comments on commit 6c1fb2e

Please sign in to comment.