From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web11.4380.1585884404820617321 for ; Thu, 02 Apr 2020 20:26:44 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: bob.c.feng@intel.com) IronPort-SDR: EDs5m4YmBJFSLmCsLPbUcyjboVQmN3Cy7TAh+PPjoz2vGgolTZTkidsMUIYqFa0ODW+vrtBHoD 5gd+r5wdpDmQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2020 20:26:44 -0700 IronPort-SDR: GEXw2K0CoEiGvAS7PY3eSl6LoPmZbHOLy7ygHPUxEk9wacR+ltfTLSmn4AIQn6pG5ggiokKzfE 7dXXf6j75otA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,338,1580803200"; d="scan'208";a="253230396" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga006.jf.intel.com with ESMTP; 02 Apr 2020 20:26:43 -0700 Received: from shsmsx605.ccr.corp.intel.com (10.109.6.215) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 2 Apr 2020 20:26:43 -0700 Received: from shsmsx601.ccr.corp.intel.com (10.109.6.141) by SHSMSX605.ccr.corp.intel.com (10.109.6.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 3 Apr 2020 11:26:41 +0800 Received: from shsmsx601.ccr.corp.intel.com ([10.109.6.141]) by SHSMSX601.ccr.corp.intel.com ([10.109.6.141]) with mapi id 15.01.1713.004; Fri, 3 Apr 2020 11:26:41 +0800 From: "Bob Feng" To: "devel@edk2.groups.io" , "michael.kubacki@outlook.com" CC: "Gao, Liming" Subject: Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Update Edk2ToolsBuild.py to use multiple threads on Linux Thread-Topic: [edk2-devel] [PATCH v1 1/1] BaseTools: Update Edk2ToolsBuild.py to use multiple threads on Linux Thread-Index: AQHWCRDyyXFsYwO3AkuNKtz5l3ez+qhmvNSw Date: Fri, 3 Apr 2020 03:26:41 +0000 Message-ID: <21c3c9c9ffa7403697ddae235560c81e@intel.com> References: In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.36] MIME-Version: 1.0 Return-Path: bob.c.feng@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable This change is good to me. Reviewed-by: Bob C Feng -----Original Message----- From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Mich= ael Kubacki Sent: Friday, April 3, 2020 1:05 AM To: devel@edk2.groups.io Cc: Feng, Bob C ; Gao, Liming Subject: [edk2-devel] [PATCH v1 1/1] BaseTools: Update Edk2ToolsBuild.py t= o use multiple threads on Linux From: Sean Brogan REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2640 Azure Pipelines agents have 2 threads. This commit has been shown to reduc= e the build time in half on those agents. Cc: Bob C Feng Cc: Liming Gao Signed-off-by: Michael Kubacki --- BaseTools/Edk2ToolsBuild.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/BaseTools/Edk2ToolsBuild.py b/BaseTools/Edk2ToolsBuild.py ind= ex 057d2e9e0633..1ea8187de693 100644 --- a/BaseTools/Edk2ToolsBuild.py +++ b/BaseTools/Edk2ToolsBuild.py @@ -11,6 +11,7 @@ import os import sys import logging import argparse +import multiprocessing from edk2toolext import edk2_logging from edk2toolext.environment import self_describing_environment from edk= 2toolext.base_abstract_invocable import BaseAbstractInvocable @@ -141,7 +14= 2,8 @@ class Edk2ToolsBuild(BaseAbstractInvocable): return ret =20 elif self.tool_chain_tag.lower().startswith("gcc"): - ret =3D RunCmd("make", "-C .", workingdir=3Dshell_env.get_she= ll_var("EDK_TOOLS_PATH")) + cpu_count =3D self.GetCpuThreads() + ret =3D RunCmd("make", f"-C . -j {cpu_count}",=20 + workingdir=3Dshell_env.get_shell_var("EDK_TOOLS_PATH")) if ret !=3D 0: raise Exception("Failed to build.") =20 @@ -154,6 +156,18 @@ class Edk2ToolsBuild(BaseAbstractInvocable): logging.critical("Tool Chain not supported") return -1 =20 + def GetCpuThreads(self) -> int: + ''' Function to return number of cpus. If error return 1''' + cpus =3D 1 + try: + cpus =3D multiprocessing.cpu_count() + except: + # from the internet there are cases where cpu_count is not im= plemented. + # will handle error by just doing single proc build + pass + return cpus + + =20 def main(): Edk2ToolsBuild().Invoke() -- 2.16.3.windows.1