make: accelerate tagging process
Subsystems (2)
cover make: accelerate tagging process
The tags generation takes about 5 minutes on my working station, which is comparable to building the whole localyesconfig.
This series adds support for parallel execution of ctags, and caching of the intermediate tags. With that, the tagging performance numbers with
time make -j8 ALLSOURCE_ARCHS=all tags
look like:
real user sys Clean tags build before 4m40.797s 4m14.229s 0m39.341s Clean tags build after 1m39.203s 9m1.450s 2m7.552s Single file update 0m7.738s 0m7.042s 0m4.031s Unchanged sources 0m0.722s 0m0.482s 0m0.304s
The cache is compressed and takes less than 10% of the tags file. The caching doesn't measurably affect clean tags build performance.
Yury Norov (2):
make: parallelize tags generation
make: cache per-directory tags
.gitignore | 1 + Documentation/kbuild/kbuild.rst | 48 ++++++ Makefile | 6 +- scripts/Makefile.tags | 15 ++ scripts/tags.sh | 266 ++++++++++++++++++++++++++++++-- 5 files changed, 323 insertions(+), 13 deletions(-) create mode 100644 scripts/Makefile.tags
Signature · 1 line
2.53.0
PATCH 1/2 make: parallelize tags generation
Generate per-directory tags in parallel with Exuberant or Universal Ctags. A recursive make shares the caller's jobserver, allowing make -jN tags to schedule directory jobs concurrently, then join them to get the traditional tags file.
Allow compiled-source discovery to find no source references in a batch of .cmd files, while still propagating grep errors.
The performance of the current vs parallel tags generation with
time make -j8 ALLSOURCE_ARCHS=all tags
is:
real user sys Before: 4m40.797s 4m14.229s 0m39.341s After: 1m39.203s 9m1.450s 2m7.552s
--- Documentation/kbuild/kbuild.rst | 9 +++ Makefile | 5 +- scripts/Makefile.tags | 9 +++ scripts/tags.sh | 137 +++++++++++++++++++++++++++++--- 4 files changed, 148 insertions(+), 12 deletions(-) create mode 100644 scripts/Makefile.tags
Documentation/kbuild/kbuild.rst +9 -0
@@ -317,6 +317,15 @@ To get all available archs you can also specify all. E.g.:: $ make ALLSOURCE_ARCHS=all tags +With Exuberant or Universal Ctags, ``make -jN tags`` generates tags for +directories in parallel and merges them into a single sorted ``tags`` file. +The jobs share make's jobserver with other build targets. For example:: + + $ make -j8 ALLSOURCE_ARCHS=all tags + +Per-directory tag files are temporary and are removed after merging. +Every invocation regenerates the complete tags file. + IGNORE_DIRS ----------- For tags/TAGS/cscope targets, you can choose which directories won't
Makefile +4 -1
@@ -2260,7 +2260,10 @@ clean: $(clean-dirs) quiet_cmd_tags = GEN $@ cmd_tags = $(BASH) $(srctree)/scripts/tags.sh $@ -tags TAGS cscope gtags: FORCE +tags: FORCE + +$(call cmd,tags) + +TAGS cscope gtags: FORCE $(call cmd,tags) # Generate rust-project.json (a file that describes the structure of non-Cargo
scripts/Makefile.tags new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Directory tag shards share the parent make's jobserver. + +.PHONY: tags +tags: $(shell cat $(tags_tmp)/shards) + $(Q)$(BASH) $(srctree)/scripts/tags.sh tags-merge $(tags_tmp) + +%.tags: %.files + $(Q)$(BASH) $(srctree)/scripts/tags.sh tags-worker $@
scripts/tags.sh +126 -11
191 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH 2/2 make: cache per-directory tags
In reply to Yury NorovReuse directory tag files across make tags invocations. Track source files and per-directory input lists with make dependencies so only changed entries are indexed again. Reuse the source inventory and dependency rules when the selected file list is unchanged. Ignore references to missing sources in stale .cmd files before building cache lists and dependencies.
Record cache locations, so obsolete files can be pruned after a successful run, including after an earlier interrupted update.
Document manual recovery from corrupt caches and require one invocation at a time per build directory, without concurrent cache cleanup.
Mirror source directories for out-of-tree builds and keep external inputs under .tags.external in the build tree.
Caching doesn't measurably affect clean 'make tags' execution time, and substantially improves on subsequent runs:
real user sys Clean tags generation 1m39.203s 9m1.450s 2m7.552s Single file updated 0m7.738s 0m7.042s 0m4.031s Unchanged sources 0m0.722s 0m0.482s 0m0.304s
The cache is kept compressed, and occupies approximately 150 MB, less than 10% of the final tags file size.
--- .gitignore | 1 + Documentation/kbuild/kbuild.rst | 43 ++++++++- Makefile | 1 + scripts/Makefile.tags | 14 ++- scripts/tags.sh | 153 +++++++++++++++++++++++++++++--- 5 files changed, 193 insertions(+), 19 deletions(-)
.gitignore +1 -0
@@ -137,6 +137,7 @@ patches series # ctags files +.tags.* tags !tags/ TAGS
Documentation/kbuild/kbuild.rst +41 -2
49 lines not on this page · raw message
Makefile +1 -0
@@ -1810,6 +1810,7 @@ $(mrproper-dirs): $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) mrproper: clean objtool_mrproper $(mrproper-dirs) + $(Q)$(BASH) $(srctree)/scripts/tags.sh tags-clean $(call cmd,rmfiles) @find . $(RCS_FIND_IGNORE) \ \( -name '*.rmeta' \) \
scripts/Makefile.tags +10 -4
@@ -1,9 +1,15 @@ # SPDX-License-Identifier: GPL-2.0-only # Directory tag shards share the parent make's jobserver. -.PHONY: tags -tags: $(shell cat $(tags_tmp)/shards) - $(Q)$(BASH) $(srctree)/scripts/tags.sh tags-merge $(tags_tmp) +.DEFAULT_GOAL := tags +tag_shards := $(shell cat .tags.shards) -%.tags: %.files +include .tags.dependencies + +tags: $(tag_shards) .tags.shards .tags.settings \ + $(srctree)/scripts/tags.sh $(srctree)/scripts/Makefile.tags + $(Q)$(BASH) $(srctree)/scripts/tags.sh tags-merge + +%.zst: %.files .tags.settings $(srctree)/scripts/tags.sh \ + $(srctree)/scripts/Makefile.tags $(Q)$(BASH) $(srctree)/scripts/tags.sh tags-worker $@
scripts/tags.sh +140 -13
223 lines not on this page · raw message
Signature · 1 line
2.53.0