From 4f84f3d15c999611aa56151fe9f572aec05c10bd Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Thu, 16 Mar 2017 15:10:35 -0400 Subject: [PATCH] Speed up builds by increasing threads for builds Generally, OpenStack CI infrastructure workers will typically have 8 cores therefore by hardcoding the threads to 4, we miss out on valuable CPU power that can speed up builds. This patch sets the number of threads when running tests between the higher number of 4 (original value) or the number of CPU cores. Change-Id: I857507d08d91ddb5e0bccb118d15f2e2bcf4da99 --- tests/test_build.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_build.py b/tests/test_build.py index 260e12e97e..b70583748d 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -11,6 +11,7 @@ # under the License. import abc +import multiprocessing import os import sys @@ -34,7 +35,12 @@ class BuildTest(object): super(BuildTest, self).setUp() self.useFixture(log_fixture.SetLogLevel([__name__], logging.logging.INFO)) - self.build_args = [__name__, "--debug", '--threads', '4'] + + self.threads = multiprocessing.cpu_count() + if self.threads < 4: + self.threads = 4 + + self.build_args = [__name__, "--debug", '--threads', str(self.threads)] @testtools.skipUnless(os.environ.get('DOCKER_BUILD_TEST'), 'Skip the docker build test')