Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [RFCv1 2/4] pkg-generic: add step_pkg_size global instrumentation hook
Date: Tue, 10 Jun 2014 00:02:41 +0200	[thread overview]
Message-ID: <20140609220241.GK3512@free.fr> (raw)
In-Reply-To: <1402177567-8021-3-git-send-email-thomas.petazzoni@free-electrons.com>

Thomas, All,

On 2014-06-07 23:46 +0200, Thomas Petazzoni spake thusly:
> 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)/<pkgname>.filelist. It can later
> be used to determine the size contribution of each package to the
> target root filesystem.
> 
> The only limitation is that if a file is installed by a package A, and
> then overriden by a file from package B, the file will only be listed
> in $(BUILD_DIR)/A.filelist as it is the first time we will see the
> file.

If we really wanted to account for the realy package, we'd have to
somehow notice that a pacakge did change the content of a file.

So, we would need to run sha1sum on all the files in the pre-step and
the post step. Any differing line would mean a new file, or a changed
file.

See below for a proposed storage solution.

> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
>  package/pkg-generic.mk | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
> index 5116ed9..069653e 100644
> --- a/package/pkg-generic.mk
> +++ b/package/pkg-generic.mk
> @@ -55,6 +55,30 @@ define step_time
>  endef
>  GLOBAL_INSTRUMENTATION_HOOKS += step_time
>  
> +# Package size steps
> +define step_pkg_size_start
> +	echo "PKG SIZE START $(1)"
> +	(cd $(TARGET_DIR) ; find . -type f) | sort > \
> +		$(BUILD_DIR)/$(1).tmp_filelist_before

At first, I wondered if we should not store those files in the packages'
own build directory (along with the .stamp files.)

But then I went back to thinking about the second-package-to-install-a-file
issue raised in the commit log.

So, say we are able to determine what files a pacakge installs or modify
(using the sah1, for example.) Then we could just store that list in a
single file, that gets appended to package after package, and which
format would be:

package-name <TAB> path/to/file
package-name <TAB> path/to/other/file
other-package <TAB> path/to/third/file
pther-package <TAB> path/to/file             <-- override

That way, the python script has only one file to scan, which is sorted
by build-order, and the script can detect overwritten files, and even
report that, while still accounting the size to the real pacakge that
installed the file that will end up in the target.

Of course, using sha1 would slow the build quite a bit.

Thoughts?

Regards,
Yann E. MORIN.

> +endef
> +
> +define step_pkg_size_end
> +	echo "PKG SIZE END $(1)"
> +	(cd $(TARGET_DIR); find . -type f) | sort > \
> +		$(BUILD_DIR)/$(1).tmp_filelist_after
> +	diff -u $(BUILD_DIR)/$(1).tmp_filelist_before $(BUILD_DIR)/$(1).tmp_filelist_after | \
> +		grep '^\+\./' | sed 's%^\+%%' > $(BUILD_DIR)/$(1).filelist
> +	$(RM) -f $(BUILD_DIR)/$(1).tmp_filelist_before \
> +		$(BUILD_DIR)/$(1).tmp_filelist_after
> +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
>  define step_user
>  	@$(foreach user_hook, $(BR2_INSTRUMENTATION_SCRIPTS), \
> -- 
> 2.0.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'

  parent reply	other threads:[~2014-06-09 22:02 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-07 21:46 [Buildroot] [RFCv1 0/4] Generating a graph of the size installed by each package Thomas Petazzoni
2014-06-07 21:46 ` [Buildroot] [RFCv1 1/4] toolchain-external: split target installation from staging installation Thomas Petazzoni
2014-06-09 21:49   ` Yann E. MORIN
2014-06-10  8:04     ` Thomas Petazzoni
2014-06-10 16:49       ` Yann E. MORIN
2014-06-07 21:46 ` [Buildroot] [RFCv1 2/4] pkg-generic: add step_pkg_size global instrumentation hook Thomas Petazzoni
2014-06-08  2:56   ` Baruch Siach
2014-06-08  8:19     ` Thomas Petazzoni
2014-06-09 22:02   ` Yann E. MORIN [this message]
2014-06-10 16:42     ` Jérôme Pouiller
     [not found]     ` <3156840.4l9buZIenR@sagittea>
2014-06-10 16:58       ` Yann E. MORIN
2014-06-10 17:37         ` Jérôme Pouiller
2014-06-24 16:36   ` Arnout Vandecappelle
2014-06-24 16:41     ` Thomas Petazzoni
2014-06-24 16:53     ` Yann E. MORIN
2014-06-07 21:46 ` [Buildroot] [RFCv1 3/4] support/scripts: add graph-size script Thomas Petazzoni
2014-06-09 22:06   ` Yann E. MORIN
2014-06-07 21:46 ` [Buildroot] [RFCv1 4/4] Makefile: implement a graph-size target Thomas Petazzoni
2014-06-09 22:28   ` Yann E. MORIN
2014-06-07 21:54 ` [Buildroot] [RFCv1 0/4] Generating a graph of the size installed by each package Will Wagner
2014-06-08  7:42   ` Thomas Petazzoni
2014-06-24 13:05 ` Luca Ceresoli
2014-06-24 16:26   ` Yann E. MORIN
2014-06-24 16:31   ` Arnout Vandecappelle
2014-06-24 16:42     ` Thomas Petazzoni
2014-06-24 19:54     ` Luca Ceresoli
2014-06-24 20:11       ` Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140609220241.GK3512@free.fr \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox