This is an automated email from the ASF dual-hosted git repository. juergbi pushed a commit to branch jbilleter/nested-reapi in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 820c8515c3a716eb072a91acc08c8cf018cf72a9 Author: Jürg Billeter <j...@bitron.ch> AuthorDate: Fri May 23 12:36:10 2025 +0200 _context.py: Add `effective_build_max_jobs` helper --- src/buildstream/_context.py | 12 ++++++++++++ src/buildstream/_project.py | 11 +---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py index 6b0cf4123..e125e3c89 100644 --- a/src/buildstream/_context.py +++ b/src/buildstream/_context.py @@ -531,6 +531,18 @@ class Context: return self._sourcecache + @property + def effective_build_max_jobs(self) -> int: + # Based on some testing (mainly on AWS), maximum effective + # max-jobs value seems to be around 8-10 if we have enough cores + # users should set values based on workload and build infrastructure + if self.build_max_jobs == 0: + # User requested automatic max-jobs + return self.platform.get_cpu_count(8) + else: + # User requested explicit max-jobs setting + return self.build_max_jobs + # add_project(): # # Add a project to the context. diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py index b55f257fa..334462df0 100644 --- a/src/buildstream/_project.py +++ b/src/buildstream/_project.py @@ -1075,16 +1075,7 @@ class Project: # Extend variables with automatic variables and option exports # Initialize it as a string as all variables are processed as strings. - # Based on some testing (mainly on AWS), maximum effective - # max-jobs value seems to be around 8-10 if we have enough cores - # users should set values based on workload and build infrastructure - if self._context.build_max_jobs == 0: - # User requested automatic max-jobs - platform = self._context.platform - output.base_variables["max-jobs"] = str(platform.get_cpu_count(8)) - else: - # User requested explicit max-jobs setting - output.base_variables["max-jobs"] = str(self._context.build_max_jobs) + output.base_variables["max-jobs"] = str(self._context.effective_build_max_jobs) # Export options into variables, if that was requested output.options.export_variables(output.base_variables)