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 <robert.galat@nordicsemi.no>
  • Loading branch information
RobertGalatNordic committed Jun 12, 2024
1 parent cf18ce8 commit da14c09
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 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
21 changes: 15 additions & 6 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,22 @@ 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
self.update(project)
return
self.updated.add(project.name)
self.update(project)
except subprocess.CalledProcessError:
failed.append(project)

Parallel(n_jobs=-1, require='sharedmem')(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 +1095,17 @@ 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, require='sharedmem')(delayed(project_update_some)(project)
for project in projects)
self._handle_failed(self.args, failed)

def toplevel_projects(self):
Expand Down

0 comments on commit da14c09

Please sign in to comment.