public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: akpm@linux.foundation.org, mmarek@suse.cz
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH v3] tags: much faster, parallel "make tags"
Date: Fri, 8 May 2015 16:26:06 +0300	[thread overview]
Message-ID: <20150508132606.GA16613@p183.telecom.by> (raw)

ctags is single-threaded program. Split list of files to be tagged into
equal parts, 1 part for each CPU and then merge the results.

Speedup on one 2-way box I have is ~143 s => ~99 s (-31%).
On another 4-way box: ~120 s => ~65 s (-46%!).

Resulting "tags" files aren't byte-for-byte identical because ctags
program numbers anon struct and enum declarations with "__anonNNN"
symbols. If those lines are removed, "tags" file becomes byte-for-byte
identical with those generated with current code.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 scripts/tags.sh |   36 +++++++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 5 deletions(-)

--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -152,7 +152,19 @@ dogtags()
 
 exuberant()
 {
-	all_target_sources | xargs $1 -a                        \
+	rm -f .make-tags.*
+
+	all_target_sources >.make-tags.src
+	NR_CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
+	NR_LINES=$(wc -l <.make-tags.src)
+	NR_LINES=$((($NR_LINES + $NR_CPUS - 1) / $NR_CPUS))
+
+	split -a 6 -d -l $NR_LINES .make-tags.src .make-tags.src.
+
+	for i in .make-tags.src.*; do
+		N=$(echo $i | sed -e 's/.*\.//')
+		# -u: don't sort now, sort later
+		xargs <$i $1 -a -f .make-tags.$N -u		\
 	-I __initdata,__exitdata,__initconst,			\
 	-I __cpuinitdata,__initdata_memblock			\
 	-I __refdata,__attribute,__maybe_unused,__always_unused \
@@ -211,7 +223,21 @@ exuberant()
 	--regex-c='/DEFINE_PCI_DEVICE_TABLE\((\w*)/\1/v/'		\
 	--regex-c='/(^\s)OFFSET\((\w*)/\2/v/'				\
 	--regex-c='/(^\s)DEFINE\((\w*)/\2/v/'				\
-	--regex-c='/DEFINE_HASHTABLE\((\w*)/\1/v/'
+	--regex-c='/DEFINE_HASHTABLE\((\w*)/\1/v/'			\
+	&
+	done
+	wait
+	rm -f .make-tags.src .make-tags.src.*
+
+	# write header
+	$1 -f $2 /dev/null
+	# remove headers
+	for i in .make-tags.*; do
+		sed -i -e '/^!/d' $i &
+	done
+	wait
+	sort .make-tags.* >>$2
+	rm -f .make-tags.*
 
 	all_kconfigs | xargs $1 -a                              \
 	--langdef=kconfig --language-force=kconfig              \
@@ -276,7 +302,7 @@ emacs()
 xtags()
 {
 	if $1 --version 2>&1 | grep -iq exuberant; then
-		exuberant $1
+		exuberant $1 $2
 	elif $1 --version 2>&1 | grep -iq emacs; then
 		emacs $1
 	else
@@ -322,13 +348,13 @@ case "$1" in
 
 	"tags")
 		rm -f tags
-		xtags ctags
+		xtags ctags tags
 		remove_structs=y
 		;;
 
 	"TAGS")
 		rm -f TAGS
-		xtags etags
+		xtags etags TAGS
 		remove_structs=y
 		;;
 esac

             reply	other threads:[~2015-05-08 13:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-08 13:26 Alexey Dobriyan [this message]
2015-05-09  5:07 ` [PATCH v3] tags: much faster, parallel "make tags" Pádraig Brady
2015-05-10 13:26   ` Alexey Dobriyan
2015-05-10 13:53     ` Alexey Dobriyan
2015-05-10 20:58     ` Pádraig Brady
2015-05-11 20:20       ` Alexey Dobriyan
2015-05-11 20:25         ` [PATCH v4] " Alexey Dobriyan
2015-08-19 13:25           ` Michal Marek

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=20150508132606.GA16613@p183.telecom.by \
    --to=adobriyan@gmail.com \
    --cc=akpm@linux.foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.cz \
    /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