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 DA4F945DB7; Wed, 27 Nov 2024 15:57:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 156F440662; Wed, 27 Nov 2024 15:57:12 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by mails.dpdk.org (Postfix) with ESMTP id E04D54060A for ; Wed, 27 Nov 2024 15:57:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1732719428; x=1764255428; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=1pw2gvhQIht+ZTtmaolkZt7gpSCfIFFG8pMCHJLW1gg=; b=VvfkXNKWUmgM053Z9vH+dDcXVE76lo1T+lzyF2RSCJa1KwepTFA7/RKS HhXZJevS4K36OWq1+2coWEyaTbm8J2m/ok7qTXtJM7kuF3O0CGcF8mJtH U/+XDK3bHuGBzoxnrIaJlM3n1GCu6WIPO/bqBSOv4lii//NE6VaNPHAeY 1knXEpG+HzfgRzJtmagATuv62+qRZQQMiX7psoKvUBD2SDdejOtz0CWC3 hXG2gQ7uwS2QZdLI/Sx9g9cggjCFTDF+yTF4ZTsZHppz1YvKWNNs650iz Zuq/s0mF8/H3o8iVpafZg83N8pDQtLw/bXGZE1YwFkueHy2w+EiNgM9b5 g==; X-CSE-ConnectionGUID: rKwCRlYSS82Mo63D2EfH/Q== X-CSE-MsgGUID: uTjMBk3QS6KOeXfHVhqnxA== X-IronPort-AV: E=McAfee;i="6700,10204,11269"; a="32782133" X-IronPort-AV: E=Sophos;i="6.12,189,1728975600"; d="scan'208";a="32782133" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2024 06:57:08 -0800 X-CSE-ConnectionGUID: vRIHPzFyR82uAhZaCVq1cw== X-CSE-MsgGUID: YvUT0qATQ/C/cq3g/Ze/Xw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,189,1728975600"; d="scan'208";a="96911442" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by orviesa005.jf.intel.com with ESMTP; 27 Nov 2024 06:57:07 -0800 From: Anatoly Burakov To: dev@dpdk.org Subject: [PATCH v5 3/8] devtools: add script to flag unneeded dependencies Date: Wed, 27 Nov 2024 14:56:51 +0000 Message-ID: X-Mailer: git-send-email 2.43.5 In-Reply-To: References: 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 | 62 +++++++++++++++++++++++++++++++++ 1 file changed, 62 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..cbd0ca7196 --- /dev/null +++ b/devtools/find-duplicate-deps.py @@ -0,0 +1,62 @@ +#! /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 remove_attrs(ln): + """Remove attributes from a line.""" + while ln.find("[") != -1: + start = ln.find("[") + end = ln.find("]") + ln = ln[:start] + ln[end + 1 :] + return ln.strip() + + +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 = remove_attrs(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