git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Speedup bash completion loading

From
Kirill Smelkov <kirr@mns.spb.ru>
Date
Oct 5, 2009, 16:58 UTC
Message-ID
<20091005165802.GA24402@tugrik.mns.mnsspb.ru>
In-Reply-To
<20091005152504.GE9261@spearce.org>
On Mon, Oct 05, 2009 at 08:25:04AM -0700, Shawn O. Pearce wrote:
Show 10 quoted lines
> Kirill Smelkov <kirr@mns.spb.ru> wrote:
> > I've tracked down that the most time is spent warming up merge_strategy,
> > all_command & porcelain_command caches.
> 
> Nak.
> 
> The problem is, during completion when we modify the value the
> change doesn't persist beyond the current completion invocation.
> Thus there is no value in the cache, so every completion attempt
> which needs the list has to rerun the command to compute it.
Yes, my mistake.

To avoid spawning subshell on $(__git_porcelain_commands) I could come up with "caching" at the upper level, as e.g.

@@ -2107,7 +2111,10 @@ _git ()
                        --help
                        "
                        ;;
-               *)     __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
+               *)     __gitcomp "
+                       ${__git_porcelain_commandlist:=$(__git_porcelain_commands)}
+                       $(__git_aliases)
+                       " ;;


but that's ugly and not maintainable since e.g. __git_all_commands() is used in
several places.


The other possibility is to pregenerate all these lists at git build time, but
are we going to do it for things under contrib/ ?


This could have easy solution if bash provided analog of $() to call a function
and obtain either its stdout or return value without spawning subshell, but up
to now I could not find such a construct in bash's man.

I have to go, but I'll try to come up with something practical in several days.


Thanks for spotting it,
Kirill
Previous: Shawn O. PearceNext: Ted Pavlic
Message 3 of 14 in “Speedup bash completion loading”
  1. Speedup bash completion loadingKirill Smelkov, Oct 5, 2009
  2. Shawn O. PearceOct 5, 2009
  3. Kirill SmelkovOct 5, 2009
  4. Ted PavlicOct 5, 2009
  5. Kirill SmelkovOct 8, 2009
  6. Shawn O. PearceOct 8, 2009
  7. Kirill SmelkovOct 8, 2009
  8. Kirill SmelkovOct 9, 2009
  9. Shawn O. PearceOct 9, 2009
  10. Kirill SmelkovOct 9, 2009
  11. Shawn O. PearceOct 9, 2009
  12. Kirill SmelkovOct 9, 2009
  13. Shawn O. PearceOct 9, 2009
  14. Junio C HamanoOct 10, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.