From patchwork Sat Aug 17 17:18:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 1148749 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=free.fr Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hMKrl8YO"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 469n3k6P1Mz9sDQ for ; Sun, 18 Aug 2019 03:19:14 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 1494421539; Sat, 17 Aug 2019 17:19:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GempiD1+6DNJ; Sat, 17 Aug 2019 17:19:05 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 730CA21F65; Sat, 17 Aug 2019 17:18:58 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 35A051BF402 for ; Sat, 17 Aug 2019 17:18:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 243A221FF8 for ; Sat, 17 Aug 2019 17:18:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Lj54TLPKfzKu for ; Sat, 17 Aug 2019 17:18:45 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by silver.osuosl.org (Postfix) with ESMTPS id 21D8121552 for ; Sat, 17 Aug 2019 17:18:43 +0000 (UTC) Received: by mail-wr1-f43.google.com with SMTP id z1so4530413wru.13 for ; Sat, 17 Aug 2019 10:18:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ztk8YkZ3yjgBlSw5SJltzcVMWa+h5V71rlxgG+zFHpo=; b=hMKrl8YOPFq9/9znlkEkg5hHO4PPhO6pfAzO75BczB4hC04q75fuEOPjn1DQAH+Uic j0VFKY0fe7o7AVca/LjZ/w5mb4BXj5/ox2cZQNzXcV4sm1s65Y+nvZRz02LNMqZ4giA9 axvQcrSnfx3LkZCGfwA95DfF09sRq+CvAzBOYx1sk6EHzc6rmJGcO5jHSgoFmJ/wce4y 2tjehUT44VQGntk0i5bkBhkcuReBEVJPA0CfudCAxmmKyOXOjlXDRsbro9DZUXYl2zCN I2TjwAyc7M/uEdN9SXpRJiJdnMDs+ilYU5wiOP9+n/zf3CFvn9i+Zx35CH0W1tqcIBpj S1Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Ztk8YkZ3yjgBlSw5SJltzcVMWa+h5V71rlxgG+zFHpo=; b=taKv2WDLi+t0RQFbkffWokMr+7tFUZiz8Y4gQ53feOLTyH8jk2eWjb/KusSWpV5/5P 8uALaRT7Px4SXSPWOz+3iHRfk/bMswiwejmDj2g6UjrjrvXW/8nfhT5WVNfiPlfGz1tg 0qPU2guiEtvyZsIA5MMEXYCzWNnFFXht4aKU4YvpZDJevrwUb6I0DfymAIL3PHLKzES5 jAU2Pbmy2ClXYH0fMoIgEOGy+D68IITQFE5jwKVnNkp18kRe9QGEuTrh0L021wXWeLeI dWT0LM3EogpjEBd9U+l8cMf6U1tah+b0ILVMV/rA+Ou14imU0PpesCE8/oWRa65DxHRG yYOw== X-Gm-Message-State: APjAAAWu9f2+sfWLI3wZxt6raxXeuFVfiDMM4nthpiK42S/cRXuS4C6N GemkcZmzBf1TCdexP9nDQHO4c8d9 X-Google-Smtp-Source: APXvYqxBRQHmSTBS7/ME3CZGuEYJCCrWvOpmVb+CMqDdSWH5+kjZtGWh6M4ALyalqLmB0VqUZBglVQ== X-Received: by 2002:a5d:6b84:: with SMTP id n4mr17502390wrx.118.1566062321391; Sat, 17 Aug 2019 10:18:41 -0700 (PDT) Received: from localhost.localdomain (ns304657.ip-46-105-103.eu. [46.105.103.66]) by smtp.gmail.com with ESMTPSA id w13sm20864877wre.44.2019.08.17.10.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2019 10:18:41 -0700 (PDT) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Sat, 17 Aug 2019 19:18:27 +0200 Message-Id: <109be7cab508c2cc454c5294a86c5ac0cbb5d84b.1566062299.git.yann.morin.1998@free.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Buildroot] [PATCH 6/9] support/graph-size: add option to change percentage to group in Others X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Yann E. MORIN" , Thomas De Schampheleire Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Currently, we group packages that contribute less then 1%, into the "Other" category. However, in some cases, there can be a lot of very comparatively small packages, and they may not exceed this limit, and so only the "Others" category would be displayed, which is not nice. Conversely, if there are a lot of packages, most of which only so slightly exceeding this limit, then we get all of them in the graph, which is not nice either. Add a way for the developers to pass a different cut-off limit. As for the dependency graph which has BR2_GRAPH_DEPS_OPTS, add the environment variable BR2_GRAPH_SIZE_OPTS to carry those extra option (in preparation for more to come, later). Signed-off-by: Yann E. MORIN Cc: Thomas De Schampheleire --- Makefile | 3 ++- docs/manual/common-usage.txt | 12 ++++++++++++ support/scripts/size-stats | 19 +++++++++++++++---- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 406efd1ab6..e4aa074e4a 100644 --- a/Makefile +++ b/Makefile @@ -892,7 +892,8 @@ graph-size: $(Q)$(TOPDIR)/support/scripts/size-stats --builddir $(BASE_DIR) \ --graph $(GRAPHS_DIR)/graph-size.$(BR_GRAPH_OUT) \ --file-size-csv $(GRAPHS_DIR)/file-size-stats.csv \ - --package-size-csv $(GRAPHS_DIR)/package-size-stats.csv + --package-size-csv $(GRAPHS_DIR)/package-size-stats.csv \ + $(BR2_GRAPH_SIZE_OPTS) .PHONY: check-dependencies check-dependencies: diff --git a/docs/manual/common-usage.txt b/docs/manual/common-usage.txt index a36301afd5..7e78d350d4 100644 --- a/docs/manual/common-usage.txt +++ b/docs/manual/common-usage.txt @@ -102,6 +102,8 @@ to +make+ or set in the environment: xref:graph-depends[] for the accepted options * +BR2_GRAPH_DOT_OPTS+ is passed verbatim as options to the +dot+ utility to draw the dependency graph. +* +BR2_GRAPH_SIZE_OPTS+ to pass extra options to the size graph; see + xref:graph-size[] for the acepted options An example that uses config files located in the toplevel directory and in your $HOME: @@ -278,6 +280,7 @@ only other format supported is PNG: BR2_GRAPH_OUT=png make graph-build ---------------- +[[graph-size]] === Graphing the filesystem size contribution of packages When your target system grows, it is sometimes useful to understand @@ -314,6 +317,15 @@ Just like for the duration graph, a +BR2_GRAPH_OUT+ environment variable is supported to adjust the output file format. See xref:graph-depends[] for details about this environment variable. +Additionally, one may set the environment variable +BR2_GRAPH_SIZE_OPTS+ +to further control the generated graph. Accepted options are: + +* `--size-limit X`, `-l X`, will group all packages which individual + contribution is below `X` percent, to a single entry labelled _Others_ + in the graph. By default, `X=0.01`, which means packages each + contributing less than 1% are grouped under _Others_. Accepted values + are in the range `[0.0..1.0]`. + .Note The collected filesystem size data is only meaningful after a complete clean rebuild. Be sure to run +make clean all+ before using +make diff --git a/support/scripts/size-stats b/support/scripts/size-stats index eb09e0dc60..3454acd681 100755 --- a/support/scripts/size-stats +++ b/support/scripts/size-stats @@ -33,8 +33,11 @@ except ImportError: sys.stderr.write("You need python-matplotlib to generate the size graph\n") exit(1) -colors = ['#e60004', '#009836', '#2e1d86', '#ffed00', - '#0068b5', '#f28e00', '#940084', '#97c000'] + +class Config(): + size_limit = 0.01 + colors = ['#e60004', '#009836', '#2e1d86', '#ffed00', + '#0068b5', '#f28e00', '#940084', '#97c000'] # @@ -145,7 +148,7 @@ def draw_graph(pkgsize, outputf): other_value = 0 unknown_value = 0 for (p, sz) in sorted(pkgsize.items(), key=lambda x: x[1]): - if sz < (total * 0.01): + if sz < (total * Config.size_limit): other_value += sz elif p == "unknown": unknown_value = sz @@ -162,7 +165,7 @@ def draw_graph(pkgsize, outputf): plt.figure() patches, texts, autotexts = plt.pie(values, labels=labels, autopct='%1.1f%%', shadow=True, - colors=colors) + colors=Config.colors) # Reduce text size proptease = fm.FontProperties() proptease.set_size('xx-small') @@ -246,8 +249,16 @@ def main(): help="CSV output file with file size statistics") parser.add_argument("--package-size-csv", '-p', metavar="PKG_SIZE_CSV", help="CSV output file with package size statistics") + parser.add_argument("--size-limit", "-l", type=float, + help='Under this size ratio, files are accounted to ' + + 'the generic "Other" package. Default: 0.01 (1%%)') args = parser.parse_args() + if args.size_limit is not None: + if args.size_limit < 0.0 or args.size_limit > 1.0: + raise ValueError("--size-limit must be in [0.0..1.0]") + Config.size_limit = args.size_limit + # Find out which package installed what files pkgdict = build_package_dict(args.builddir)