-
Notifications
You must be signed in to change notification settings - Fork 2k
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
git prompt causes FISH to start very slowly on OS X #6625
Comments
It's a lot better (but not perfect) after I edit fish_git_prompt and have it launch git from its absolute path in Xcode.app:
|
After seeing this:
I managed to solve it. First, I did "funced fish_vcs_prompt" and deleted the following:
I then copied /usr/local/Cellar/fish/3.1.0/share/fish/functions/fish_git_prompt.fish to ~/.config/fish/functions, and edited the copy, replacing "command git" with "/Applications/Xcode.app/Contents/Developer/usr/bin/git" FISH now starts up instantly. Even with a VCS prompt. |
Yeah, it's the svn (and git?) prompt. Or maybe just disable svn by default on macOS. |
Potential hack: most people do not have homedirs that are VCS repos. On fish launch, skip doing the vcs prompt but launch no-op SVN and git commands in the background to prime it for the next prompt. |
How about checking if the xcode path exists and using it then? |
The Xcode path is going to vary - quickly resolving it ourselves is kind of tricky. Using |
Sure about that? "/Applications/Xcode.app/Contents/Developer/usr/bin/git" looks quite stable. |
absolutely sure, you could install Xcode.app anywhere - and we don't know which Xcode.app is active, Xcode.app or Xcode-beta.app or.. "my Xcode 8.app" |
"install" is the wrong word - you can put Xcode.app anywhere, it's portable-ish. It's several gigabytes so people do move it around to save space on / and stuff. |
It remains to be seen if |
(The fact that the |
Oh, and big one - some people do not install Xcode at all (it's huge) and just install the command line tools package by running |
|
Does it short circuit caching? My concern would be if it blocks for a few second the first time you run it anyhow. I'll do some testing |
Yeah, it blocks the first time you use it. I don't think there's any way around that using Apple's tools. |
I think there's a way around it by taking advantage of something else most likely cached previously and synthesizing the path. |
e.g. |
That specific case won't work, as the Maybe |
Whoops, busted example. |
Huh, interesting. If you give
So it looks like it's not even actually |
Nice! |
Ah, but if you use |
the dylib that causes the wrapping takes SDKROOT into account as well, so it should be possible once we have a way to quickly get the SDK path regardless of cache ( |
These paths aren't going to change often, so I'd propose baking the xcrun results into "set -U" universal variables instead of running xcrun each time FISH starts. And for cache invalidation: I'd just check if the path still exists, either on startup on when you display the prompt. The following script, which is meant to be executed with an ampersand, is what I have in mind:
|
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
I've noticed another issue that seems to be slowing down the prompt is locating svn (I removed my prompt since it had some unrelated information displayed):
|
Oh looks like my SVN issue was fixed by #6681 |
I think this issue can be closed, based on the fix in #6681 having been incorporated into 3.1.1 and later. Fish is speedy again! 🎉 |
Cool! Thanks! |
It's... not fixed? The svn prompt was one issue, the initial problem however was that macOS does weird things with I mean I'd personally be entirely okay with calling that an OS bug, but then I'm not using macOS. |
Yeah this isn't fixed. |
Update since the last time I commented here: this happens specifically after each reboot, because that clears $TMPDIR. It specifically takes so long because syspolicyd is spending a lot of time in the security framework checking code signing across the Xcode bundle. |
So there is a practical workaround: if $TMPDIR/xcrun_db doesn't exist, we run something like |
This prevents fish appearing to hang on launch on macOS. /usr/bin/git is a shim that finds Git in the Xcode or Command Line Tools Developer dir. There is a cache file kept in TMPRDIR that is cleared on reboot. The validity of the Xcode installation is verified as well for security reasons, causing this to be potentially really slow. This runs a git no-op command in the background when we autoload fish_git_prompt if the db file is missing on Darwin, with a self-destructing callback that repaints the commandline when it's done. If the callback function exists, it means we're currently waiting for the cold-start git command to finish, and do not print a git_prompt. Fixes fish-shell#6625
I addressed this in PR #9345. Even if fish is launched with a CWD of a git repo, the behavior is pretty pleasant now, with the prompt and command line updating as soon as the cache file exists, the VCS component just kind of pops in late. |
git on macOS has two hazards: 1. It comes "preinstalled" as a stub which pops a dialog to install command line developer tools. 2. It may populate the xcrun cache when run for the first time, which may take several seconds. We fix these as follows, both fixes limited to Darwin: 1. If git is `/usr/bin/git` and `xcode-select --print-path` fails, then do not run git automatically. 2. Second, if there is no file at `xcrun --show-cache-path`, we take it as an indication that the cache is not yet populated. In this case we run `git` in the background to populate the cache. Credit to @floam for the idea. Fixes fish-shell#9343. Fixes fish-shell#6625.
git on macOS has two hazards: 1. It comes "preinstalled" as a stub which pops a dialog to install command line developer tools. 2. It may populate the xcrun cache when run for the first time, which may take several seconds. We fix these as follows, both fixes limited to Darwin: 1. If git is `/usr/bin/git` and `xcode-select --print-path` fails, then do not run git automatically. 2. Second, if there is no file at `xcrun --show-cache-path`, we take it as an indication that the cache is not yet populated. In this case we run `git` in the background to populate the cache. Credit to @floam for the idea. Fixes fish-shell#9343. Fixes fish-shell#6625.
I had the common OS X issue where FISH would take seconds to load. It would only happen once per reboot. The first time I tried to start FISH after a reboot, it would take seconds to start. If you tried to start it again, it would start instantly. At least, until the next reboot.
I profiled it: and the cause seems to be having a prompt with VCS information in it? This absolutely jumped out at me:
I tried switching to a prompt without VCS information, and now FISH starts instantly. Even right after a reboot.
Both profile results ("FISH Profile with git prompt" and "FISH profile with minimalist prompt" are here:
https://gist.github.com/duganchen/7467164add3bcfa6cae0e2f2741ca8bc
This, more precisely, is what's taking so much time on startup:
And no, I'm (obviously) not in a git repository when FISH starts.
If I change fish_prompt_git to call git with its absolute path: well, that makes no difference:
An as for why git is so slow the first time it starts on OS X: I don't know. This takes several seconds, the first time after a reboot it runs:
The text was updated successfully, but these errors were encountered: