From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.12696.1586703623726056540 for ; Sun, 12 Apr 2020 08:00:23 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: liming.gao@intel.com) IronPort-SDR: YkqTmV5KtXqtd2Q9kotlB+Zwgq5gjqa9iIEfPMPMNlLF+L+y2GNxXshISlzdA93W2bPVCEDCbB L1rG7AFHor5A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2020 08:00:23 -0700 IronPort-SDR: TQPtF3yq67vG9ja74Al6QTWIlO77hvgdzGIku/b/0d1GuaLj3vQnSgYAdogRAV9j/k6F9mWUzh RSigroXLZ5sQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,374,1580803200"; d="scan'208";a="287658794" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga002.fm.intel.com with ESMTP; 12 Apr 2020 08:00:23 -0700 Received: from shsmsx606.ccr.corp.intel.com (10.109.6.216) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 12 Apr 2020 08:00:22 -0700 Received: from shsmsx604.ccr.corp.intel.com (10.109.6.214) by SHSMSX606.ccr.corp.intel.com (10.109.6.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sun, 12 Apr 2020 23:00:20 +0800 Received: from shsmsx604.ccr.corp.intel.com ([10.109.6.214]) by SHSMSX604.ccr.corp.intel.com ([10.109.6.214]) with mapi id 15.01.1713.004; Sun, 12 Apr 2020 23:00:20 +0800 From: "Liming Gao" To: "devel@edk2.groups.io" , "michael.kubacki@outlook.com" CC: "Feng, Bob C" 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: AQHWCRDukigD3S3MG0Sjfyexp0NGl6h1pAZQ Date: Sun, 12 Apr 2020 15:00:20 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action x-originating-ip: [10.239.127.36] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Michael K= ubacki > 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= to use multiple threads on Linux >=20 > From: Sean Brogan >=20 > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2640 >=20 > Azure Pipelines agents have 2 threads. This commit has been shown to > reduce the build time in half on those agents. >=20 > Cc: Bob C Feng > Cc: Liming Gao > Signed-off-by: Michael Kubacki > --- > BaseTools/Edk2ToolsBuild.py | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) >=20 > diff --git a/BaseTools/Edk2ToolsBuild.py b/BaseTools/Edk2ToolsBuild.py > index 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 edk2toolext.base_abstract_invocable import BaseAbstractInvocable > @@ -141,7 +142,8 @@ class Edk2ToolsBuild(BaseAbstractInvocable): > return ret >=20 > elif self.tool_chain_tag.lower().startswith("gcc"): > - ret =3D RunCmd("make", "-C .", workingdir=3Dshell_env.get_s= hell_var("EDK_TOOLS_PATH")) > + cpu_count =3D self.GetCpuThreads() > + ret =3D RunCmd("make", f"-C . -j {cpu_count}", 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 = implemented. > + # will handle error by just doing single proc build > + pass > + return cpus > + > + >=20 > def main(): > Edk2ToolsBuild().Invoke() > -- > 2.16.3.windows.1 >=20 >=20 >=20