linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] kbuild: shrink .cache.mk when it exceeds 1000 lines
@ 2017-10-13 11:25 Masahiro Yamada
  2017-10-13 15:05 ` Doug Anderson
  2017-10-18 16:54 ` Masahiro Yamada
  0 siblings, 2 replies; 3+ messages in thread
From: Masahiro Yamada @ 2017-10-13 11:25 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Douglas Anderson, Sam Ravnborg, Masahiro Yamada,
	Marcin Nowakowski, Matthias Kaehlcke, Cao jin, Arnd Bergmann,
	Mark Charlebois, linux-kernel, Josh Poimboeuf, Ingo Molnar

The cache files are only cleaned away by "make clean".  If you continue
incremental builds, the cache files will grow up little by little.
It is not a big deal in general use cases because compiler flags do not
change quite often.

However, if you do build-test for various architectures, compilers, and
kernel configurations, you will end up with huge cache files soon.

When the cache file exceeds 1000 lines, shrink it down to 500 by "tail".
The Least Recently Added lines are cut. (not Least Recently Used)
I hope it will work well enough.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v2:
  - Simplify code per Douglas Anderson

 scripts/Kbuild.include | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 4203fff..d939490 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -102,6 +102,12 @@ make-cache := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/,$(if $(obj),$(obj)/)).cach
 $(make-cache): ;
 -include $(make-cache)
 
+# If cache exceeds 1000 lines, shrink it down to 500.
+ifneq ($(word 1000,$(filter __cached_%, $(.VARIABLES))),)
+$(shell tail -n 500 $(make-cache) > $(make-cache).tmp; \
+	mv $(make-cache).tmp $(make-cache))
+endif
+
 # Usage: $(call __sanitize-opt,Hello=Hola$(comma)Goodbye Adios)
 #
 # Convert all '$', ')', '(', '\', '=', ' ', ',', ':' to '_'
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] kbuild: shrink .cache.mk when it exceeds 1000 lines
  2017-10-13 11:25 [PATCH v2] kbuild: shrink .cache.mk when it exceeds 1000 lines Masahiro Yamada
@ 2017-10-13 15:05 ` Doug Anderson
  2017-10-18 16:54 ` Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Doug Anderson @ 2017-10-13 15:05 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Linux Kbuild mailing list, Sam Ravnborg, Marcin Nowakowski,
	Matthias Kaehlcke, Cao jin, Arnd Bergmann, Mark Charlebois,
	linux-kernel, Josh Poimboeuf, Ingo Molnar

Hi,

On Fri, Oct 13, 2017 at 4:25 AM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> The cache files are only cleaned away by "make clean".  If you continue
> incremental builds, the cache files will grow up little by little.
> It is not a big deal in general use cases because compiler flags do not
> change quite often.
>
> However, if you do build-test for various architectures, compilers, and
> kernel configurations, you will end up with huge cache files soon.
>
> When the cache file exceeds 1000 lines, shrink it down to 500 by "tail".
> The Least Recently Added lines are cut. (not Least Recently Used)
> I hope it will work well enough.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
> Changes in v2:
>   - Simplify code per Douglas Anderson
>
>  scripts/Kbuild.include | 6 ++++++
>  1 file changed, 6 insertions(+)

Thanks for doing this!

Reviewed-by: Douglas Anderson <dianders@chromium.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] kbuild: shrink .cache.mk when it exceeds 1000 lines
  2017-10-13 11:25 [PATCH v2] kbuild: shrink .cache.mk when it exceeds 1000 lines Masahiro Yamada
  2017-10-13 15:05 ` Doug Anderson
@ 2017-10-18 16:54 ` Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2017-10-18 16:54 UTC (permalink / raw)
  To: Linux Kbuild mailing list
  Cc: Douglas Anderson, Sam Ravnborg, Masahiro Yamada,
	Marcin Nowakowski, Matthias Kaehlcke, Cao jin, Arnd Bergmann,
	Mark Charlebois, Linux Kernel Mailing List, Josh Poimboeuf,
	Ingo Molnar

2017-10-13 20:25 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> The cache files are only cleaned away by "make clean".  If you continue
> incremental builds, the cache files will grow up little by little.
> It is not a big deal in general use cases because compiler flags do not
> change quite often.
>
> However, if you do build-test for various architectures, compilers, and
> kernel configurations, you will end up with huge cache files soon.
>
> When the cache file exceeds 1000 lines, shrink it down to 500 by "tail".
> The Least Recently Added lines are cut. (not Least Recently Used)
> I hope it will work well enough.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>

Applied to linux-kbuild/kbuild.

-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-18 16:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-13 11:25 [PATCH v2] kbuild: shrink .cache.mk when it exceeds 1000 lines Masahiro Yamada
2017-10-13 15:05 ` Doug Anderson
2017-10-18 16:54 ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).