mgalgs / fuzzy_bash_completion

Fuzzy tab completion for bash.
94 stars 9 forks source link

Very slow sourcing #4

Closed orschiro closed 11 years ago

orschiro commented 11 years ago

Hi there,

First of all, thanks for this excellent piece of software. I was looking for an easy tab completion for quite a while!

I added source ~/.fuzzy_bash_completion to .bashrc. However, since then I notice a very slow startup of my interactive shell. It takes around ~3 seconds until the prompt is shown.

Is this normal and can this somehow be improved?

Thanks!

mgalgs commented 11 years ago

Well, source'ing should be almost instantaneous, the slow part is actually replacing the completion specs. I'm guessing you're using the "recommended" function, fuzzy_replace_filedir_xspec, to set up completion? That guy is slow... _fuzzy_replace_compspecs_by_function appears to be the real culprit, although I haven't dug in any further than that...

After some brief testing it looks like we might be able to throw in a grep or two to avoid doing so much regex matching inside those while loops... I'll have a look.

mgalgs commented 11 years ago

Pushed a fix. Thanks for prodding me to finally fix this :).

orschiro commented 11 years ago

Thanks! Indeed I was using fuzzy_replace_filedir_xspec. I updated your script but also commented out fuzzy_replace_filedir_xspec and now use fuzzy_setup_for_command cd and fuzzy_setup_for_command rm to set up only the completions I really need.

Now opening a terminal does not show any delay anymore. :+1:

mgalgs commented 11 years ago

Awesome. By the way, fuzzy_replace_filedir_xspec should be fast now too.

orschiro commented 11 years ago

@mgalgs

Depends on how you define fast, I guess.

See the following screencast. The first terminal session uses specific fuzzy_setup_for_command rm and fuzzy_setup_for_command cd in bashrc. The second session uses fuzzy_replace_filedir_xspec.

http://videobin.org/+718/8y5.html

But never mind, it's a minor issue I can live with.

mgalgs commented 11 years ago

Hmm, from the screencast I couldn't tell how long it was actually spending in fuzzy_replace_filedir_xspec... Can you just run that function from your terminal? On my machine it only takes about .3 seconds to run:

[mitchelh@mitchelh-linux ~]$ fuzzy_restore_all_specs >/dev/null 
[mitchelh@mitchelh-linux ~]$ time fuzzy_replace_filedir_xspec 

real    0m0.297s
user    0m0.020s
sys     0m0.033s
[mitchelh@mitchelh-linux ~]$ 
orschiro commented 11 years ago
~ $ fuzzy_restore_all_specs >/dev/null 

~ $ time fuzzy_replace_filedir_xspec 

real    0m0.575s
user    0m0.043s
sys 0m0.053s

~ $ 

Would you say this is significantly too much time or simply a fact of my "old" Thinkpad X200T?

mgalgs commented 11 years ago

Half a second looks about right. On Nov 8, 2013 6:20 AM, "Robert Orzanna" notifications@github.com wrote:

~ $ fuzzy_restore_all_specs >/dev/null

~ $ time fuzzy_replace_filedir_xspec

real 0m0.575s user 0m0.043s sys 0m0.053s

~ $

Would you say this is significantly too much time or simply a fact of my "old" Thinkpad X200T?

— Reply to this email directly or view it on GitHubhttps://github.com/mgalgs/fuzzy_bash_completion/issues/4#issuecomment-28065452 .

orschiro commented 11 years ago

Thanks for your support. I consider this as finally resolved. :)