* [Buildroot] [PATCHv6 0/4] Generate package size statistics
@ 2015-10-17 13:33 Thomas Petazzoni
2015-10-17 13:33 ` [Buildroot] [PATCHv6 1/4] pkg-generic: add step_pkg_size global instrumentation hook Thomas Petazzoni
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2015-10-17 13:33 UTC (permalink / raw)
To: buildroot
Hello,
Here is the sixth iteration of the patches adding a graph-size
feature, which mainly allows to generate a pie chart of the size
contribution of each package to the overall root filesystem size.
This code is also available at:
http://git.free-electrons.com/users/thomas-petazzoni/buildroot/log/?h=size-stats-v6
Changes since v5:
- Rebased on top of the latest master.
- Added Reviewed-by/Tested-by from Yann on "pkg-generic: add
step_pkg_size global instrumentation hook".
- Added Tested-by from Yann on "support/scripts: add size-stats
script."
- Rename the "size-stats" target back to "graph-size" so that it
matches graph-depends and graph-build, even if graph-size also
generates some CSV files (which are more
by-products). Consequently, I've dropped the Tested-by/Reviewed-by
tags from Yann and Ryan.
- As suggested by Yann and Ryan, generate the CSV files in
$(O)/graphs/ rather than $(O)/build, since they are really products
of the "gaph-size" targets, and people are more likely to find them
here.
- Use the $(GRAPHS_DIR) variable instead of open-coding
$(BASE_DIR)/graphs/.
- Fix the wording of the manual regarding what graph-size is doing,
and fix the path to the generated PDF file. Also, take into account
the change of the Makefile target name, and the location of the
generated CSV files. All suggested by Yann E. Morin.
Changes since v4:
- Rebased on top of the latest master.
- Now that the skeleton logic has been moved to a regular Buildroot
package, remove all the skeleton specific handling in the
size-stats script, as well as the passing of the --skeleton-path
from the main Makefile to the size-stats script.
- Added Reviewed-by/Tested-by from Ryan Barnett on "pkg-generic: add
step_pkg_size global instrumentation hook".
- Rework the commit log of "pkg-generic: add step_pkg_size global
instrumentation hook" to not mention the Config.in option that no
longer exists, and instead explain why we are doing the data
collection unconditionally. Reported by Romain Naour.
- Display the total filesystem on the generated graph. Suggested by
Ryan Barnett.
- Call matplotlib.use('Agg') to make sure matplotlib doesn't try to
connect to a X server. Suggested by Claython Shotwell.
- Added Reviewed-by/Tested-by from Ryan Barnett on "Makefile:
implement a size-stats target".
- Minor tweaks in the manual, suggested by Ryan Barnett. Also added
Reviewed-by/Tested-by from Ryan on the manual patch.
Changes since v3:
- Remove the BR2_COLLECT_FILE_SIZE_STATS option, and collect the
necessary data unconditionally. This was suggested by Yann
E. Morin, who did some testing of the performance impact, and found
that it was so insignificant that it is negligible. See Yann's
analysis at
http://lists.busybox.net/pipermail/buildroot/2015-February/119431.html.
- Store the temporary files listing the files before/after inside
each package build directory, rather than in $(BUILD_DIR)
directly. This was suggested by Yann E. Morin.
They are now named .br_filelist_before and .br_filelist_after. They
are also no longer removed after the step_pkg_size_end hook, as
they don't consume that much space and could be useful for
analysis. If anyone finds that annoying, I'll be happy to change
this back to remove them.
- As suggested by Arnout, make a number of improvements to the
size-stats Python script:
* Use collections.defaultdict()
* Use a dict of tuples (package name, file size) for the filesdict,
instead of a dict of dict containing just two entries.
* Factorize code between build_skeleton_dict() and
build_package_dict() into a add_file() function.
* Use [2:] instead of .replace("./", "") to remove the leading "./"
in relative file paths returned by find.
* Many other small things: one digit for percentages, use sum()
when possible, rename pkgdict to filesdict where it makes sense,
etc.
- In the main Makefile:
* Use mkdir -p instead of install -d, as suggested by Arnout.
* Use $(Q) instead of @, as suggested by Arnout
* Do not cd into $(CONFIG_DIR), as it would break out of tree
build, since the path to the skeleton is passed as a relative
path.
- Add a new patch updating the manual with a new section describing
this feature.
Changes since v2:
- Use print0 in find and -0 in xargs to support spaces in filenames,
just in case. Suggested by J?r?me Pouiller.
- Support custom skeleton locations, instead of assuming the skeleton
comes from system/skeleton.
- Fix the size-stats target to actually call the size-stats script,
and not graph-size, which was the old name of the script in
previous versions of the series.
- Fix usage of the size-stats target in out of tree build
situations. For consistency reasons, we chose to mimic what
graph-depends already does, even if size-stats does not necessarily
need to be executed from within CONFIG_DIR.
- Add one patch to make sure that 'make clean' removes the graphs/
subdirectory in the output directory, which wasn't done today. This
issue isn't specific to size-stats, and already existed with
graph-build and graph-depends.
Changes since v1:
- Improve the logic to properly take into account packages that
overwrite files installed by other packages.
- Make the new pkg_step hook optional.
- Extend the facility to not only generate a graph, but also CSV
files. As a consequence, everything was renamed from 'graph-size'
to 'size-stats'.
Best regards,
Thomas
Thomas Petazzoni (4):
pkg-generic: add step_pkg_size global instrumentation hook
support/scripts: add size-stats script
Makefile: implement a graph-size target
docs/manual: add section about size graphing
Makefile | 8 ++
docs/manual/common-usage.txt | 41 ++++++++
package/pkg-generic.mk | 32 +++++++
support/scripts/size-stats | 217 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 298 insertions(+)
create mode 100755 support/scripts/size-stats
--
2.6.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCHv6 1/4] pkg-generic: add step_pkg_size global instrumentation hook
2015-10-17 13:33 [Buildroot] [PATCHv6 0/4] Generate package size statistics Thomas Petazzoni
@ 2015-10-17 13:33 ` Thomas Petazzoni
2015-10-17 13:33 ` [Buildroot] [PATCHv6 2/4] support/scripts: add size-stats script Thomas Petazzoni
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2015-10-17 13:33 UTC (permalink / raw)
To: buildroot
This patch adds a global instrumentation hook that collects the list
of files installed in $(TARGET_DIR) by each package, and stores this
list into a file called $(BUILD_DIR)/packages-file-list.txt. It can
later be used to determine the size contribution of each package to
the target root filesystem.
Note that in order to detect if a file installed by one package is
later overriden by another package, we calculate the md5 of installed
files and compare them at each installation of a new package.
Collecting the list of files installed by each package is done
unconditionally, as tests have shown that the performance impact of
doing this is negligible.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Ryan Barnett <ryanbarnett3@gmail.com>
Tested-by: Ryan Barnett <ryanbarnett3@gmail.com>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
package/pkg-generic.mk | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 76ec295..ffef4d3 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -55,6 +55,38 @@ define step_time
endef
GLOBAL_INSTRUMENTATION_HOOKS += step_time
+# Hooks to collect statistics about installed files
+
+# This hook will be called before the target installation of a
+# package. We store in a file named .br_filelist_before the list of
+# files currently installed in the target. Note that the MD5 is also
+# stored, in order to identify if the files are overwritten.
+define step_pkg_size_start
+ (cd $(TARGET_DIR) ; find . -type f -print0 | xargs -0 md5sum) | sort > \
+ $($(PKG)_DIR)/.br_filelist_before
+endef
+
+# This hook will be called after the target installation of a
+# package. We store in a file named .br_filelist_after the list of
+# files (and their MD5) currently installed in the target. We then do
+# a diff with the .br_filelist_before to compute the list of files
+# installed by this package.
+define step_pkg_size_end
+ (cd $(TARGET_DIR); find . -type f -print0 | xargs -0 md5sum) | sort > \
+ $($(PKG)_DIR)/.br_filelist_after
+ comm -13 $($(PKG)_DIR)/.br_filelist_before $($(PKG)_DIR)/.br_filelist_after | \
+ while read hash file ; do \
+ echo "$(1),$${file}" >> $(BUILD_DIR)/packages-file-list.txt ; \
+ done
+endef
+
+define step_pkg_size
+ $(if $(filter install-target,$(2)),\
+ $(if $(filter start,$(1)),$(call step_pkg_size_start,$(3))) \
+ $(if $(filter end,$(1)),$(call step_pkg_size_end,$(3))))
+endef
+GLOBAL_INSTRUMENTATION_HOOKS += step_pkg_size
+
# User-supplied script
ifneq ($(BR2_INSTRUMENTATION_SCRIPTS),)
define step_user
--
2.6.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Buildroot] [PATCHv6 2/4] support/scripts: add size-stats script
2015-10-17 13:33 [Buildroot] [PATCHv6 0/4] Generate package size statistics Thomas Petazzoni
2015-10-17 13:33 ` [Buildroot] [PATCHv6 1/4] pkg-generic: add step_pkg_size global instrumentation hook Thomas Petazzoni
@ 2015-10-17 13:33 ` Thomas Petazzoni
2015-10-17 13:33 ` [Buildroot] [PATCHv6 3/4] Makefile: implement a graph-size target Thomas Petazzoni
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2015-10-17 13:33 UTC (permalink / raw)
To: buildroot
This new script uses the data collected by the step_pkg_size
instrumentation hook to generate a pie chart of the size contribution
of each package to the target root filesystem, and two CSV files with
statistics about the package size and file size. To achieve this, it
looks at each file in $(TARGET_DIR), and using the
packages-file-list.txt information collected by the step_pkg_size
hook, it determines to which package the file belongs. It is therefore
able to give the size installed by each package.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
support/scripts/size-stats | 217 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 217 insertions(+)
create mode 100755 support/scripts/size-stats
diff --git a/support/scripts/size-stats b/support/scripts/size-stats
new file mode 100755
index 0000000..54685f6
--- /dev/null
+++ b/support/scripts/size-stats
@@ -0,0 +1,217 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2014 by Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import sys
+import os
+import os.path
+import argparse
+import csv
+import collections
+
+try:
+ import matplotlib
+ matplotlib.use('Agg')
+ import matplotlib.font_manager as fm
+ import matplotlib.pyplot as plt
+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']
+
+#
+# This function adds a new file to 'filesdict', after checking its
+# size. The 'filesdict' contain the relative path of the file as the
+# key, and as the value a tuple containing the name of the package to
+# which the file belongs and the size of the file.
+#
+# filesdict: the dict to which the file is added
+# relpath: relative path of the file
+# fullpath: absolute path to the file
+# pkg: package to which the file belongs
+#
+def add_file(filesdict, relpath, abspath, pkg):
+ if not os.path.exists(abspath):
+ return
+ if os.path.islink(abspath):
+ return
+ sz = os.stat(abspath).st_size
+ filesdict[relpath] = (pkg, sz)
+
+#
+# This function returns a dict where each key is the path of a file in
+# the root filesystem, and the value is a tuple containing two
+# elements: the name of the package to which this file belongs and the
+# size of the file.
+#
+# builddir: path to the Buildroot output directory
+#
+def build_package_dict(builddir):
+ filesdict = {}
+ with open(os.path.join(builddir, "build", "packages-file-list.txt")) as filelistf:
+ for l in filelistf.readlines():
+ pkg, fpath = l.split(",")
+ # remove the initial './' in each file path
+ fpath = fpath.strip()[2:]
+ fullpath = os.path.join(builddir, "target", fpath)
+ add_file(filesdict, fpath, fullpath, pkg)
+ return filesdict
+
+#
+# This function builds a dictionary that contains the name of a
+# package as key, and the size of the files installed by this package
+# as the value.
+#
+# filesdict: dictionary with the name of the files as key, and as
+# value a tuple containing the name of the package to which the files
+# belongs, and the size of the file. As returned by
+# build_package_dict.
+#
+# builddir: path to the Buildroot output directory
+#
+def build_package_size(filesdict, builddir):
+ pkgsize = collections.defaultdict(int)
+
+ for root, _, files in os.walk(os.path.join(builddir, "target")):
+ for f in files:
+ fpath = os.path.join(root, f)
+ if os.path.islink(fpath):
+ continue
+ frelpath = os.path.relpath(fpath, os.path.join(builddir, "target"))
+ if not frelpath in filesdict:
+ print("WARNING: %s is not part of any package" % frelpath)
+ pkg = "unknown"
+ else:
+ pkg = filesdict[frelpath][0]
+
+ pkgsize[pkg] += os.path.getsize(fpath)
+
+ return pkgsize
+
+#
+# Given a dict returned by build_package_size(), this function
+# generates a pie chart of the size installed by each package.
+#
+# pkgsize: dictionary with the name of the package as a key, and the
+# size as the value, as returned by build_package_size.
+#
+# outputf: output file for the graph
+#
+def draw_graph(pkgsize, outputf):
+ total = sum(pkgsize.values())
+ labels = []
+ values = []
+ other_value = 0
+ for (p, sz) in pkgsize.items():
+ if sz < (total * 0.01):
+ other_value += sz
+ else:
+ labels.append("%s (%d kB)" % (p, sz / 1000.))
+ values.append(sz)
+ labels.append("Other (%d kB)" % (other_value / 1000.))
+ values.append(other_value)
+
+ plt.figure()
+ patches, texts, autotexts = plt.pie(values, labels=labels,
+ autopct='%1.1f%%', shadow=True,
+ colors=colors)
+ # Reduce text size
+ proptease = fm.FontProperties()
+ proptease.set_size('xx-small')
+ plt.setp(autotexts, fontproperties=proptease)
+ plt.setp(texts, fontproperties=proptease)
+
+ plt.suptitle("Filesystem size per package", fontsize=18, y=.97)
+ plt.title("Total filesystem size: %d kB" % (total / 1000.), fontsize=10, y=.96)
+ plt.savefig(outputf)
+
+#
+# Generate a CSV file with statistics about the size of each file, its
+# size contribution to the package and to the overall system.
+#
+# filesdict: dictionary with the name of the files as key, and as
+# value a tuple containing the name of the package to which the files
+# belongs, and the size of the file. As returned by
+# build_package_dict.
+#
+# pkgsize: dictionary with the name of the package as a key, and the
+# size as the value, as returned by build_package_size.
+#
+# outputf: output CSV file
+#
+def gen_files_csv(filesdict, pkgsizes, outputf):
+ total = 0
+ for (p, sz) in pkgsizes.items():
+ total += sz
+ with open(outputf, 'w') as csvfile:
+ wr = csv.writer(csvfile, delimiter=',', quoting=csv.QUOTE_MINIMAL)
+ wr.writerow(["File name",
+ "Package name",
+ "File size",
+ "Package size",
+ "File size in package (%)",
+ "File size in system (%)"])
+ for f, (pkgname, filesize) in filesdict.items():
+ pkgsize = pkgsizes[pkgname]
+ wr.writerow([f, pkgname, filesize, pkgsize,
+ "%.1f" % (float(filesize) / pkgsize * 100),
+ "%.1f" % (float(filesize) / total * 100)])
+
+
+#
+# Generate a CSV file with statistics about the size of each package,
+# and their size contribution to the overall system.
+#
+# pkgsize: dictionary with the name of the package as a key, and the
+# size as the value, as returned by build_package_size.
+#
+# outputf: output CSV file
+#
+def gen_packages_csv(pkgsizes, outputf):
+ total = sum(pkgsizes.values())
+ with open(outputf, 'w') as csvfile:
+ wr = csv.writer(csvfile, delimiter=',', quoting=csv.QUOTE_MINIMAL)
+ wr.writerow(["Package name", "Package size", "Package size in system (%)"])
+ for (pkg, size) in pkgsizes.items():
+ wr.writerow([pkg, size, "%.1f" % (float(size) / total * 100)])
+
+parser = argparse.ArgumentParser(description='Draw build time graphs')
+
+parser.add_argument("--builddir", '-i', metavar="BUILDDIR", required=True,
+ help="Buildroot output directory")
+parser.add_argument("--graph", '-g', metavar="GRAPH",
+ help="Graph output file (.pdf or .png extension)")
+parser.add_argument("--file-size-csv", '-f', metavar="FILE_SIZE_CSV",
+ 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")
+args = parser.parse_args()
+
+# Find out which package installed what files
+pkgdict = build_package_dict(args.builddir)
+
+# Collect the size installed by each package
+pkgsize = build_package_size(pkgdict, args.builddir)
+
+if args.graph:
+ draw_graph(pkgsize, args.graph)
+if args.file_size_csv:
+ gen_files_csv(pkgdict, pkgsize, args.file_size_csv)
+if args.package_size_csv:
+ gen_packages_csv(pkgsize, args.package_size_csv)
--
2.6.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Buildroot] [PATCHv6 3/4] Makefile: implement a graph-size target
2015-10-17 13:33 [Buildroot] [PATCHv6 0/4] Generate package size statistics Thomas Petazzoni
2015-10-17 13:33 ` [Buildroot] [PATCHv6 1/4] pkg-generic: add step_pkg_size global instrumentation hook Thomas Petazzoni
2015-10-17 13:33 ` [Buildroot] [PATCHv6 2/4] support/scripts: add size-stats script Thomas Petazzoni
@ 2015-10-17 13:33 ` Thomas Petazzoni
2015-10-17 14:06 ` Yann E. MORIN
2015-10-17 13:33 ` [Buildroot] [PATCHv6 4/4] docs/manual: add section about size graphing Thomas Petazzoni
2015-10-17 14:14 ` [Buildroot] [PATCHv6 0/4] Generate package size statistics Thomas Petazzoni
4 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2015-10-17 13:33 UTC (permalink / raw)
To: buildroot
This commit implements a graph-size target that calls the script of
the same name to generate the graph and CSV files related to package
and file sizes.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
Makefile | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Makefile b/Makefile
index 181d446..c871393 100644
--- a/Makefile
+++ b/Makefile
@@ -686,6 +686,13 @@ graph-depends: graph-depends-requirements
|tee $(GRAPHS_DIR)/$(@).dot \
|dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) -o $(GRAPHS_DIR)/$(@).$(BR_GRAPH_OUT)
+graph-size:
+ $(Q)mkdir -p $(GRAPHS_DIR)
+ $(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
+
else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
all: menuconfig
@@ -903,6 +910,7 @@ endif
@echo ' manual-epub - build manual in ePub'
@echo ' graph-build - generate graphs of the build times'
@echo ' graph-depends - generate graph of the dependency tree'
+ @echo ' graph-size - generate stats of the filesystem size'
@echo ' list-defconfigs - list all defconfigs (pre-configured minimal systems)'
@echo
@echo 'Miscellaneous:'
--
2.6.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Buildroot] [PATCHv6 4/4] docs/manual: add section about size graphing
2015-10-17 13:33 [Buildroot] [PATCHv6 0/4] Generate package size statistics Thomas Petazzoni
` (2 preceding siblings ...)
2015-10-17 13:33 ` [Buildroot] [PATCHv6 3/4] Makefile: implement a graph-size target Thomas Petazzoni
@ 2015-10-17 13:33 ` Thomas Petazzoni
2015-10-17 14:09 ` Yann E. MORIN
2015-10-17 14:14 ` [Buildroot] [PATCHv6 0/4] Generate package size statistics Thomas Petazzoni
4 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2015-10-17 13:33 UTC (permalink / raw)
To: buildroot
Document the new graph-size target and its possibilities.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
docs/manual/common-usage.txt | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/docs/manual/common-usage.txt b/docs/manual/common-usage.txt
index 5b27b1f..3ae05c7 100644
--- a/docs/manual/common-usage.txt
+++ b/docs/manual/common-usage.txt
@@ -273,6 +273,47 @@ only other format supported is PNG:
BR2_GRAPH_OUT=png make graph-build
----------------
+=== Graphing the filesystem size contribution of packages
+
+When your target system grows, it is sometimes useful to understand
+how much each Buildroot package is contributing to the overall root
+filesystem size. To help with such an analysis, Buildroot collects
+data about files installed by each package and using this data,
+generates a graph and CSVs files detailing the size contribution of
+the different packages.
+
+To generate these data after a build, run:
+
+----------------
+make graph-size
+----------------
+
+This will generate:
+
+* +output/graphs/graph-size.pdf+, a pie chart of the contribution of
+ each package to the overall root filesystem size
+
+* +output/graphs/package-size-stats.csv+, a CSV file giving the size
+ contribution of each package to the overall root filesystem size
+
+* +output/graphs/file-size-stats.csv+, a CSV file giving the size
+ contribution of each installed file to the package it belongs, and
+ to the overall filesystem size.
+
+This +size-stats+ target requires the Python Matplotlib library to be
+installed (+python-matplotlib+ on most distributions), and also the
++argpase+ module if you're using a Python version older than 2.7
+(+python-argparse+ on most distributions).
+
+Just like for the duration graph, a +BR2_GRAPH_OUT+ environment is
+supported to adjust the output file format. See xref:graph-depends[]
+for details about this environment variable.
+
+.Note
+The collected filesystem size data is only meaningful after a complete
+clean rebuild. Be sure to run +make clean all+ before using +make
+size-stats+.
+
include::eclipse-integration.txt[]
include::advanced.txt[]
--
2.6.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Buildroot] [PATCHv6 3/4] Makefile: implement a graph-size target
2015-10-17 13:33 ` [Buildroot] [PATCHv6 3/4] Makefile: implement a graph-size target Thomas Petazzoni
@ 2015-10-17 14:06 ` Yann E. MORIN
0 siblings, 0 replies; 8+ messages in thread
From: Yann E. MORIN @ 2015-10-17 14:06 UTC (permalink / raw)
To: buildroot
Thomas, All,
On 2015-10-17 15:33 +0200, Thomas Petazzoni spake thusly:
> This commit implements a graph-size target that calls the script of
> the same name to generate the graph and CSV files related to package
> and file sizes.
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Regards,
Yann E. MORIN.
> ---
> Makefile | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index 181d446..c871393 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -686,6 +686,13 @@ graph-depends: graph-depends-requirements
> |tee $(GRAPHS_DIR)/$(@).dot \
> |dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) -o $(GRAPHS_DIR)/$(@).$(BR_GRAPH_OUT)
>
> +graph-size:
> + $(Q)mkdir -p $(GRAPHS_DIR)
> + $(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
> +
> else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
>
> all: menuconfig
> @@ -903,6 +910,7 @@ endif
> @echo ' manual-epub - build manual in ePub'
> @echo ' graph-build - generate graphs of the build times'
> @echo ' graph-depends - generate graph of the dependency tree'
> + @echo ' graph-size - generate stats of the filesystem size'
> @echo ' list-defconfigs - list all defconfigs (pre-configured minimal systems)'
> @echo
> @echo 'Miscellaneous:'
> --
> 2.6.2
>
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCHv6 4/4] docs/manual: add section about size graphing
2015-10-17 13:33 ` [Buildroot] [PATCHv6 4/4] docs/manual: add section about size graphing Thomas Petazzoni
@ 2015-10-17 14:09 ` Yann E. MORIN
0 siblings, 0 replies; 8+ messages in thread
From: Yann E. MORIN @ 2015-10-17 14:09 UTC (permalink / raw)
To: buildroot
Thomas, All,
On 2015-10-17 15:33 +0200, Thomas Petazzoni spake thusly:
> Document the new graph-size target and its possibilities.
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Regards,
Yann E. MORIN.
> ---
> docs/manual/common-usage.txt | 41 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> diff --git a/docs/manual/common-usage.txt b/docs/manual/common-usage.txt
> index 5b27b1f..3ae05c7 100644
> --- a/docs/manual/common-usage.txt
> +++ b/docs/manual/common-usage.txt
> @@ -273,6 +273,47 @@ only other format supported is PNG:
> BR2_GRAPH_OUT=png make graph-build
> ----------------
>
> +=== Graphing the filesystem size contribution of packages
> +
> +When your target system grows, it is sometimes useful to understand
> +how much each Buildroot package is contributing to the overall root
> +filesystem size. To help with such an analysis, Buildroot collects
> +data about files installed by each package and using this data,
> +generates a graph and CSVs files detailing the size contribution of
> +the different packages.
> +
> +To generate these data after a build, run:
> +
> +----------------
> +make graph-size
> +----------------
> +
> +This will generate:
> +
> +* +output/graphs/graph-size.pdf+, a pie chart of the contribution of
> + each package to the overall root filesystem size
> +
> +* +output/graphs/package-size-stats.csv+, a CSV file giving the size
> + contribution of each package to the overall root filesystem size
> +
> +* +output/graphs/file-size-stats.csv+, a CSV file giving the size
> + contribution of each installed file to the package it belongs, and
> + to the overall filesystem size.
> +
> +This +size-stats+ target requires the Python Matplotlib library to be
> +installed (+python-matplotlib+ on most distributions), and also the
> ++argpase+ module if you're using a Python version older than 2.7
> +(+python-argparse+ on most distributions).
> +
> +Just like for the duration graph, a +BR2_GRAPH_OUT+ environment is
> +supported to adjust the output file format. See xref:graph-depends[]
> +for details about this environment variable.
> +
> +.Note
> +The collected filesystem size data is only meaningful after a complete
> +clean rebuild. Be sure to run +make clean all+ before using +make
> +size-stats+.
> +
> include::eclipse-integration.txt[]
>
> include::advanced.txt[]
> --
> 2.6.2
>
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCHv6 0/4] Generate package size statistics
2015-10-17 13:33 [Buildroot] [PATCHv6 0/4] Generate package size statistics Thomas Petazzoni
` (3 preceding siblings ...)
2015-10-17 13:33 ` [Buildroot] [PATCHv6 4/4] docs/manual: add section about size graphing Thomas Petazzoni
@ 2015-10-17 14:14 ` Thomas Petazzoni
4 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2015-10-17 14:14 UTC (permalink / raw)
To: buildroot
Hello,
On Sat, 17 Oct 2015 15:33:41 +0200, Thomas Petazzoni wrote:
> Thomas Petazzoni (4):
> pkg-generic: add step_pkg_size global instrumentation hook
> support/scripts: add size-stats script
> Makefile: implement a graph-size target
> docs/manual: add section about size graphing
Series applied. Thanks Yann for testing/reviewing!
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-10-17 14:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-17 13:33 [Buildroot] [PATCHv6 0/4] Generate package size statistics Thomas Petazzoni
2015-10-17 13:33 ` [Buildroot] [PATCHv6 1/4] pkg-generic: add step_pkg_size global instrumentation hook Thomas Petazzoni
2015-10-17 13:33 ` [Buildroot] [PATCHv6 2/4] support/scripts: add size-stats script Thomas Petazzoni
2015-10-17 13:33 ` [Buildroot] [PATCHv6 3/4] Makefile: implement a graph-size target Thomas Petazzoni
2015-10-17 14:06 ` Yann E. MORIN
2015-10-17 13:33 ` [Buildroot] [PATCHv6 4/4] docs/manual: add section about size graphing Thomas Petazzoni
2015-10-17 14:09 ` Yann E. MORIN
2015-10-17 14:14 ` [Buildroot] [PATCHv6 0/4] Generate package size statistics Thomas Petazzoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox