From patchwork Fri Aug 2 12:44:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 142860 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DF7224571A; Fri, 2 Aug 2024 14:44:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7D61C42E6F; Fri, 2 Aug 2024 14:44:31 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) by mails.dpdk.org (Postfix) with ESMTP id 78D3D42E6A for ; Fri, 2 Aug 2024 14:44:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1722602671; x=1754138671; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eM/azOtX1cXV+MKgYNfwfJzl7uJd5N6J0rLgT3kyA7Q=; b=HYlWZiA99LyV2pxpSbL5O3e2OYH7+XZSHCWy5bN0u1S9tXTTOHHB/TzR 0vutClCHzsnoulxaPTNxJK6LgzOEWkvTHQuRAMNn0mmI57EquFzrHsXKH Yz1mYsDdRy8yeWoPL7Q06QKyXk8uKREYXKUou8tvTPD3rhDFl6bmBlg8U YFuFYiB2OLwRqymLLcoUOYEpaWv0LrM9GH45aS71NjUk4iZmbrAx/IDap 3vFVpW+OxO9d77uSb6/aSZIqMkz0ibxYYRPSzLKUR8LPd2zdDFb5kezWq Ms1bubwxeWFmjc0hwqeEkRX3zNmGHJYSn8xhpuW3dSafKstd1W+Dr2NQN Q==; X-CSE-ConnectionGUID: j0RBOL/gQf2Z2qXhH6TO+g== X-CSE-MsgGUID: 64/St+STQfOVxdCzD5Qwpg== X-IronPort-AV: E=McAfee;i="6700,10204,11152"; a="20499769" X-IronPort-AV: E=Sophos;i="6.09,257,1716274800"; d="scan'208";a="20499769" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2024 05:44:29 -0700 X-CSE-ConnectionGUID: mLXDAGmORYCk0iUSfRaR+A== X-CSE-MsgGUID: 1idF8CfUT2aoxVBd2/b9+Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,257,1716274800"; d="scan'208";a="56149897" Received: from silpixa00401385.ir.intel.com ([10.237.214.25]) by orviesa008.jf.intel.com with ESMTP; 02 Aug 2024 05:44:28 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: ferruh.yigit@amd.com, konstantin.ananyev@huawei.com, anatoly.burakov@intel.com, Bruce Richardson Subject: [PATCH v2 2/7] devtools: add script to flag unneeded dependencies Date: Fri, 2 Aug 2024 13:44:06 +0100 Message-ID: <20240802124411.485430-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240802124411.485430-1-bruce.richardson@intel.com> References: <20240730145508.551075-1-bruce.richardson@intel.com> <20240802124411.485430-1-bruce.richardson@intel.com> MIME-Version: 1.0 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 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)