Skip to content

Commit

Permalink
pythongh-89792: unhardcode freeze test build parallelism.
Browse files Browse the repository at this point in the history
base it on the number of cpus, don't use more than max(2, 2/3).
  • Loading branch information
gpshead committed Feb 12, 2023
1 parent 1d19423 commit 81ce27c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Tools/freeze/test/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,25 @@ def prepare(script=None, outdir=None):
if not MAKE:
raise UnsupportedError('make')

cores = os.cpu_count()
if cores and cores >= 3:
# this test is most often run as part of the whole suite with a lot
# of other tests running in parallel, from 1-2 vCPU systems up to
# people's NNN core beasts. Don't attempt to use it all.
parallel = f'-j{cores*2//3}'
else:
parallel = '-j2'

# Build python.
print(f'building python in {builddir}...')
print(f'building python {parallel=} in {builddir}...')
if os.path.exists(os.path.join(srcdir, 'Makefile')):
# Out-of-tree builds require a clean srcdir.
_run_quiet([MAKE, '-C', srcdir, 'clean'])
_run_quiet([MAKE, '-C', builddir, '-j8'])
_run_quiet([MAKE, '-C', builddir, parallel])

# Install the build.
print(f'installing python into {prefix}...')
_run_quiet([MAKE, '-C', builddir, '-j8', 'install'])
_run_quiet([MAKE, '-C', builddir, 'install'])
python = os.path.join(prefix, 'bin', 'python3')

return outdir, scriptfile, python
Expand Down

0 comments on commit 81ce27c

Please sign in to comment.