git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Speedup bash completion loading
@ 2009-10-05 10:03 Kirill Smelkov
  2009-10-05 15:25 ` Shawn O. Pearce
  0 siblings, 1 reply; 14+ messages in thread
From: Kirill Smelkov @ 2009-10-05 10:03 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git, Kirill Smelkov

On my slow laptop (P3 700MHz), system-wide bash completions take too
much time to load (> 1s), and significant fraction of this time is spent
loading git-completion.bash:

    $ time bash -c '. git-completion.bash'  # before this patch

    real    0m0.317s
    user    0m0.250s
    sys     0m0.060s

I've tracked down that the most time is spent warming up merge_strategy,
all_command & porcelain_command caches.

Since git is not used in each and every interactive xterm, I think it
would be perfectly ok to load completion support with cold caches, and
then load needed thing lazily.

As __git_merge_stratiegies(), __git_all_commands() &
__git_porcelain_command() already cache their results, we can safely
remove associated cache initialization code and be done with it:

    $ time bash -c '. git-completion.bash'  # after this patch

    real    0m0.069s
    user    0m0.050s
    sys     0m0.020s

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
---
 contrib/completion/git-completion.bash |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 2c2a0d4..4c09d41 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -340,7 +340,6 @@ __git_merge_strategies ()
 	}'
 }
 __git_merge_strategylist=
-__git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)
 
 __git_complete_file ()
 {
@@ -505,7 +504,6 @@ __git_all_commands ()
 	done
 }
 __git_all_commandlist=
-__git_all_commandlist="$(__git_all_commands 2>/dev/null)"
 
 __git_porcelain_commands ()
 {
@@ -596,7 +594,6 @@ __git_porcelain_commands ()
 	done
 }
 __git_porcelain_commandlist=
-__git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
 
 __git_aliases ()
 {
-- 
1.6.5.rc2.17.gdbc1b

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

end of thread, other threads:[~2009-10-10  1:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-05 10:03 [PATCH] Speedup bash completion loading Kirill Smelkov
2009-10-05 15:25 ` Shawn O. Pearce
2009-10-05 16:58   ` Kirill Smelkov
2009-10-05 19:18     ` Ted Pavlic
2009-10-08 13:27       ` Kirill Smelkov
2009-10-08 15:02         ` Shawn O. Pearce
2009-10-08 15:10           ` Kirill Smelkov
2009-10-09  9:09           ` Kirill Smelkov
2009-10-09 14:46             ` Shawn O. Pearce
2009-10-09 15:21               ` Kirill Smelkov
2009-10-09 15:39                 ` Shawn O. Pearce
2009-10-09 16:08                   ` Kirill Smelkov
2009-10-09 16:14                     ` Shawn O. Pearce
2009-10-10  0:57                       ` Junio C Hamano

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).