Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hydro slowdown Fish's launch #7

Closed
Princesseuh opened this issue Jan 19, 2021 · 15 comments
Closed

Hydro slowdown Fish's launch #7

Princesseuh opened this issue Jan 19, 2021 · 15 comments
Labels
bug Something isn't working

Comments

@Princesseuh
Copy link

Princesseuh commented Jan 19, 2021

Even though Hydro is much faster than Tide at rendering the prompt, like advertised (measured using time fish_prompt)

Hydro:

Executed in  172,00 micros    fish           external
   usr time  159,00 micros  159,00 micros    0,00 micros
   sys time   15,00 micros   15,00 micros    0,00 micro

Tide:

Executed in    2,06 millis    fish           external
   usr time    2,04 millis    2,04 millis    0,00 micros
   sys time    0,01 millis    0,01 millis    0,00 micros

It comes with the downside that it slowdown the launch (or perhaps the shutdown?) of Fish by roughly 8-10ms (mesured using hyperfine with the command fish -i -c "exit") on my machine:

Hydro:

Benchmark #1: fish -i -c "exit"
  Time (mean ± σ):      24.7 ms ±   1.4 ms    [User: 20.1 ms, System: 6.0 ms]
  Range (min … max):    20.1 ms …  30.3 ms    102 runs

Tide:

Benchmark #1: fish -i -c "exit"
  Time (mean ± σ):      16.7 ms ±   1.1 ms    [User: 14.1 ms, System: 3.5 ms]
  Range (min … max):    11.8 ms …  18.6 ms    146 runs

This is with the default settings on Hydro and the Pure preset on Tide with few icons. I can reproduce those results by uninstalling / reinstalling both prompts. My config.fish file is available here if needed

@jorgebucaran
Copy link
Owner

Need for speed ey? I can't notice any difference using time fish -c exit between Hydro and function fish_prompt; echo; end. But I suppose Hyperfine can see things Fish's time can't.

I suspect the problem is here:

hydro/conf.d/hydro.fish

Lines 101 to 105 in 0c7e1be

for color in hydro_color_{pwd,git,error,prompt,duration}
function $color --on-variable $color --inherit-variable color
set --query $color && set --global _$color (set_color $$color)
end && $color
end

I was actually planning to remove all that because it always takes me a while to remember what I am doing there. The goal was to cache the color codes, in the hope that would make fish_prompt faster.

Thanks for the detailed report!

@jorgebucaran
Copy link
Owner

I installed Hyperfine, followed your instructions, and this is what I got:

Tide

~/tank/hydro main
❯ hyperfine fish -i -c "exit" --warmup=10
Benchmark #1: fish
  Time (mean ± σ):       5.7 ms ±   0.5 ms    [User: 3.8 ms, System: 1.4 ms]
  Range (min … max):     5.3 ms …   9.0 ms    303 runs

Hydro

~/t/hydro main ❱ hyperfine fish -i -c "exit" --warmup=10
Benchmark #1: fish
  Time (mean ± σ):       5.6 ms ±   0.5 ms    [User: 3.6 ms, System: 1.5 ms]
  Range (min … max):     5.1 ms …   9.2 ms    395 runs

Specs

macOS Big Sur
MacBook Pro (15-inch, 2019)
Intel UHD Graphics 630 1536 MB
32 GB 2400 MHz DDR4
2.4 GHz 8コアIntel Core i9

@jorgebucaran
Copy link
Owner

I'm also running the latest Fish from HEAD (not 3.1.2).

@Princesseuh
Copy link
Author

Hmm, that's weird (computers yay). I'll try a few things

Okay, so turns out running without -i makes the benchmarks much more closer so maybe it's something in my config?

Tide

Benchmark #1: fish
  Time (mean ± σ):      11.5 ms ±   1.1 ms    [User: 9.4 ms, System: 2.3 ms]
  Range (min … max):     7.0 ms …  13.4 ms    179 runs

Hydro

Benchmark #1: fish
  Time (mean ± σ):      11.1 ms ±   1.0 ms    [User: 8.9 ms, System: 2.4 ms]
  Range (min … max):     6.9 ms …  13.5 ms    198 runs

This is with hyperfine fish -c "exit", adding a warmup doesn't change the results

@jorgebucaran
Copy link
Owner

Try commenting out everything in your config.fish just to be sure?

@Princesseuh

This comment has been minimized.

@jorgebucaran
Copy link
Owner

スクリーンショット 2021-01-20 3 58 07

Can't reproduce the issue. I didn't even comment out my config.fish where I customize Hydro colors (which will trigger --on-variable handlers and do nothing in the case of Tide). I have absolutely nothing else in my config.fish.

@Princesseuh
Copy link
Author

It's effectively the -i flag that cause the 10ms difference in my case, removing my config (apart from the part where I load fisher plugins) doesn't change this, neither does removing any functions that run on fish_prompt event.

I'm gonna try on a completely empty config with all my plugins removed, sorry for the inconvenience 😅

@jorgebucaran
Copy link
Owner

No problem. By the way, are you using a custom $fisher_path? You don't need to do this unless you have a custom $fisher_path, but I see no indication of that in your config.fish, hence the question.

@Princesseuh
Copy link
Author

Removed my entire Fish folder so all the screenshots are with the base config of Fish (I'm using fish, version 3.1.2 however, not HEAD), Fisher and the installed prompt in their base form (no customization on Tide)

Base prompt:

image

Hydro:

image

Tide:

image

Trying out with HEAD of Fish, I get the more or less the same results (albeit everything seems a bit faster, cool stuff), still an unusual spike with Hydro with -i. I'm not sure what more I can provide than that, sorry! Here's a few random infos if anything can tip you off maybe:

Config:
WM: Sway 1.5.1 (so Wayland)
Terminal: alacritty 0.6.0
CPU: i7-3930k
GPU: GTX 1080ti (using Nouveau)

No problem. By the way, are you using a custom $fisher_path? You don't need to do this unless you have a custom $fisher_path, but I see no indication of that in your config.fish, hence the question.

Yes, the variable is defined here. I was originally hoping to have all the fisher stuff outside of config.fish but it turns out I needed plugins to be loaded at the end of config.fish for a reason I don't remember

@jorgebucaran
Copy link
Owner

Actually, just hyperfine "fish -i -c exit" is still correct (and easier to read). Did you comment out everything in your config.fish? It'd be nice if you could do that and try again.

@Princesseuh
Copy link
Author

Princesseuh commented Jan 19, 2021

Actually, just hyperfine "fish -i -c exit" is still correct (and easier to read)

True, I just mindlessly copy-pasted it (doesn't affect the results just in case you wonder)

Did you comment out everything in your config.fish? It'd be nice if you could do that and try again.

These screenshots are using a completely vanilla Fish config (removed the entire fish config folder), so there's nothing to comment.

Unless you mean on my normal configuration, in which case commenting everything did not change the results, neither did removing any functions that ran on prompt

@jorgebucaran
Copy link
Owner

I found it. The problem is here

_hydro_prompt && _hydro_pwd

@jorgebucaran
Copy link
Owner

That part appears to be a code relic from an earlier shape of this prompt, but we no longer need it. We were running it twice!

As for _hydro_pwd, we can delay it until the fish_prompt event handler fires. 💯

@jorgebucaran jorgebucaran added the bug Something isn't working label Jan 19, 2021
@jorgebucaran
Copy link
Owner

Thank you, @Princesseuh! It's looking a lot better now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants