From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B25B745903; Wed, 4 Sep 2024 17:09:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AD4FF4278C; Wed, 4 Sep 2024 17:08:49 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by mails.dpdk.org (Postfix) with ESMTP id C2C5C42759 for ; Wed, 4 Sep 2024 17:08:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725462527; x=1756998527; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=jZuzEVD67ftBHLFhkb4gHgEVAnctIIAy7gwzZz7EWys=; b=Bn30wc8qNVEd+Cuuqy+lPSrNcaVdFzs3YimD5edYJUTDSwb0XXHR9x11 8unmizMDz2R2DJG6YFEFTtquyU5nwYcpMzEDYf3HDDWgNo8XqKVNPtrwr IvwWDMeQofzkOPfH5TAZzR0MQnegcptesmfsycUL1jnMT+mwkdzMMyQ+K w8vktgNCO7xl5dZrxok2VzIkKypoU2vhJpTHbmPuZ1FboT6Ic4+sF8CPO DCehq4i8I2t96cXzplPgmRXepi8XznqTAHZVi/BvI7Mjd/mVuTWRNOXTF 10rcJ+n+DV4/MK6yiSEpriNFKNfShlWKWT8160wS6XX+1fHNR5/Y1beyY w==; X-CSE-ConnectionGUID: qmpDocHRQdKndo6q9s7j9Q== X-CSE-MsgGUID: OPw+u4N9RySfV5Pi3Rx95g== X-IronPort-AV: E=McAfee;i="6700,10204,11185"; a="23641082" X-IronPort-AV: E=Sophos;i="6.10,202,1719903600"; d="scan'208";a="23641082" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2024 08:08:47 -0700 X-CSE-ConnectionGUID: yZUfpk3eQQq/DWP2emqKDg== X-CSE-MsgGUID: cvK5ZhCAQmechANoqkMJWw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,202,1719903600"; d="scan'208";a="96107845" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by fmviesa001.fm.intel.com with ESMTP; 04 Sep 2024 08:08:46 -0700 From: Anatoly Burakov To: dev@dpdk.org Subject: [PATCH v3 3/8] devtools: add script to flag unneeded dependencies Date: Wed, 4 Sep 2024 16:08:31 +0100 Message-ID: <6da0eb59d1967f42b612bbbaa74c6ddc3cbf7b7d.1725462264.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: References: <20240730145508.551075-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Bruce Richardson While not a serious problem, DPDK components often list more dependencies than are actually necessary to build, due to the use of recursive dependencies. In extreme cases, such as with core libraries, this can lead to longer configuration times due to meson having to deduplicate long lists of dependencies. Therefore we can add a script to identify when a component has got unnecessary dependencies listed. Signed-off-by: Bruce Richardson --- devtools/find-duplicate-deps.py | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 devtools/find-duplicate-deps.py diff --git a/devtools/find-duplicate-deps.py b/devtools/find-duplicate-deps.py new file mode 100755 index 0000000000..b1eacf21ce --- /dev/null +++ b/devtools/find-duplicate-deps.py @@ -0,0 +1,53 @@ +#! /usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Intel Corporation + +"""Identify any superfluous dependencies listed in DPDK deps graph.""" + +import sys + +all_deps = {} + + +class dep: + """Holds a component and its dependencies.""" + + def __init__(self, name, dep_names): + """Create and process a component and its deps.""" + self.name = name.strip('" ') + self.base_deps = [all_deps[dn.strip('" ')] for dn in dep_names] + self.recursive_deps = [] + for d in self.base_deps: + self.recursive_deps.extend(d.base_deps) + self.recursive_deps.extend(d.recursive_deps) + self.extra_deps = [] + for d in self.base_deps: + if d in self.recursive_deps: + self.extra_deps.append(d.name) + if self.extra_deps: + print(f'{self.name}: extra deps {self.extra_deps}') + + def dict_add(self, d): + """Add this object to a dictionary by name.""" + d[self.name] = self + + +def main(argv): + """Read the dependency tree from a dot file and process it.""" + if len(argv) != 2: + print(f'Usage: {argv[0]} /deps.dot', file=sys.stderr) + sys.exit(1) + + with open(argv[1]) as f: + for ln in f.readlines(): + ln = ln.strip() + if '->' in ln: + name, deps = ln.split('->') + deps = deps.strip(' {}') + dep(name, deps.split(',')).dict_add(all_deps) + elif ln.startswith('"') and ln.endswith('"'): + dep(ln.strip('"'), []).dict_add(all_deps) + + +if __name__ == '__main__': + main(sys.argv) -- 2.43.5