Commit 318f4a05 authored by Kirill Smelkov's avatar Kirill Smelkov

slaprunner: Make njobs calculation more explicit and simple

Currently we use '%d' and string formatting on max(1, ncpu / cpu-usage-ratio),
because `ncpu / cpu-usage-ratio` is float:

    In [1]: from __future__ import division

    In [2]: 8 / 4
    Out[2]: 2.0

and jinja2 uses future division by default:

    {{ 8 / 4 }}   ->   2.0

We can however make things more explicit, by explicitly using integer
division (// operator) and this way avoid the need for '%d' and string
formatting.

/cc @jerome, @cedric.leninivin
parent e9a35c48
......@@ -156,7 +156,7 @@ mode = 0644
[template-supervisord]
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/template/${:filename}
md5sum = 05f86e84e6f079aa08e57839b218f7f6
md5sum = ca93b052aea55208d167b46f91c50f32
location = ${buildout:parts-directory}/${:_buildout_section_name_}
filename = supervisord.conf.in
download-only = true
......
......@@ -27,7 +27,7 @@ stdout_logfile = {{ supervisord['no_logfile'] }}
stderr_logfile = {{ supervisord['no_logfile'] }}
directory = {{ supervisord['directory'] }}
{# how many parallel build jobs to spawn when compiling software -#}
{% set njobs = '%d' % builtin.max(1, (multiprocessing.cpu_count() / builtin.int(slapparameter_dict.get('cpu-usage-ratio', 4)))) -%}
{% set njobs = builtin.max(1, (multiprocessing.cpu_count() // builtin.int(slapparameter_dict.get('cpu-usage-ratio', 4)))) -%}
environment = PATH="{{- supervisord['path'] -}}",MAKEFLAGS="-j{{ njobs }}"
[program:{{- supervisord['slapgrid-cp'] -}}]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment