Repository navigation
Conversation
|
Thanks for this! Testing this, it subjectively feels substantially slower, and instrumenting it shows a slowdown of ~9x when tab completing as |
|
For that case (i.e. we don't need a command), there are two things that spring to mind: The first is splitting the if in The second is saving a list of aliases and custom commands for later use, i.e. not calling git all the time but doing it once when the completion is loaded. This would speed up later completion, but the problem is that it would only update when the completion is re-loaded - which is when fish is started if I understand correctly. Also, how are you instrumenting it? For me it's pretty quick (half a second delay at most for the case without the space), so I'm having a hard time testing. |
|
Half a second on one computer can mean half of ten seconds on another computer. What computer are you using? I hope that you would not make |
|
An Acer Aspire 5750g, with an i7 and spinning rust (HDD), no SSD, so it's certainly not top-of-the-line. I'm using Archlinux, so I've got the newest git, linux kernel, etc. The main issue why I brought that time up was that I can't really go by feeling since the difference between, say, 0.5 seconds, 0.4 seconds and 0.2 seconds is hard to notice. So I need to measure. |
|
Yeah, I am using archlinux too. But I use it on raspberry pi, so it will be easy to measure, but I don't know how. |
|
The way I measured was to get the current time at the beginning of |
|
Urgh, I just noticed I broke completion after aliases (my Want me to do a fixup commit or fix all problems then create a new PR? |
|
You can tweak this PR, either by making a new commit or by overwriting one (i.e. |
|
So, I've measured, and I can't find a large difference. For the old version, I get around 210ms. This is with hot cache, cold cache results are all over the place (between 200 and 800ms), completely inconclusive and not relevant to practical usage. My guess is something different: For each completion, That's not too much, considering the one git call in "__fish_git_using_command" is executed a whopping 27 times per completion though (once per git-command), and the (The new git config | sed is about 0.003s slower for me than the old one, multiplied by 27 that's 8.1msec - measured using bash's |
|
Thanks @faho! What was the scenario you were testing? |
|
|
|
Any more thoughts on this? The first two commits should be fairly uncontroversial and usable without the third. I haven't come up with a way to speed it up. |
|
For master branch, For faho/git-completion branch, commit |
|
In case it is an issue with sed, I've just pushed a commit that replaces it. @ridiculousfish can you re-test? |
|
@faho I had tested your git-completion branch, commit I had also found some error reporting unused function when running Thanks for showing me how to use benchmark, @ridiculousfish. But I only find the following useful: diff --git a/complete.cpp b/complete.cpp
index 1f3cc65..c4705e6 100644
--- a/complete.cpp
+++ b/complete.cpp
@@ -1841,6 +1841,8 @@ bool completer_t::try_complete_user(const wcstring &str)
void complete(const wcstring &cmd_with_subcmds, std::vector<completion_t> &comps, completion_request_flags_t flags)
{
+ double before = timef();
+
/* Determine the innermost subcommand */
const wchar_t *cmdsubst_begin, *cmdsubst_end;
parse_util_cmdsubst_extent(cmd_with_subcmds.c_str(), cmd_with_subcmds.size(), &cmdsubst_begin, &cmdsubst_end);
@@ -2083,6 +2085,10 @@ void complete(const wcstring &cmd_with_subcmds, std::vector<completion_t> &comps
}
comps = completer.get_completions();
+ if (! (flags & COMPLETION_REQUEST_AUTOSUGGESTION)) {
+ double after = timef();
+ fprintf(stderr, "<%ls> %f msec\n", cmd_with_subcmds.c_str(), (after - before) * 1000.);
+ }
} |
|
@ridiculousfish: Do you want this in or should I drop it? |
|
Please leave it open, I want to revisit it. |
|
@ridiculousfish It seems to have be faster, is there any reason why you would not want to merge it? |
Might print unrelated crap if we try to complete while not in a git repository
I.e. "git --help <TAB>"
I.e. not "git <TAB>", but "git some-alias <TAB>" I broke this when fixing option-before-command
Might improve performance
Not all of them and only those that don't accept arguments for now Fixes fish-shell#1996
|
@ridiculousfish: Ping? |
|
It seems that the completions are a bit slower on the first run but faster on most of the time. |
This is already done by fish before calling the completion. It breaks completion with combiners (fish-shell#2025) and also with wrappers. (This does not include git because that's better solved in fish-shell#2145)
|
Pushed now, I'll redo the rest if there's any need. |
|
In |
|
That's weird, I'll see if I can find something. I've now written a different __fish_git_needs_command implementation that matches more closely how git behaves (turns out subcommand-options aren't valid before the subcommands) and should be quicker since it run function __fish_git_needs_command
set cmd (commandline -opc)
if [ (count $cmd) -eq 1 ]
return 0
else
set -l skip_next 1
# Skip first word because it's "git" or a wrapper
for c in $cmd[2..-1]
test $skip_next -eq 0; and set skip_next 1; and continue
# git can only take a few options before a command, these are the ones mentioned in the "git" man page
# e.g. `git --follow log` is wrong, `git --help log` is okay (and `git --help log $branch` is superfluous but works)
switch $c
# General options that can still take a command
case "--help" "-p" "--paginate" "--no-pager" "--bare" "--no-replace-objects" --{literal,glob,noglob,icase}-pathspecs --{exec-path,git-dir,work-tree,namespace}"=*"
continue
# General options with an argument we need to skip. The option=value versions have already been handled above
case --{exec-path,git-dir,work-tree,namespace}
set skip_next 0
continue
# General options that cause git to do something and exit - these behave like commands and everything after them is ignored
case "--version" --{html,man,info}-path
return 1
# We assume that any bare word that's not an argument to a general option is a command
case "*"
return 1
end
end
return 0
end
return 1
end |
No description provided.