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

[BUG]: eval "$(gh copilot alias -- bash)" takes 0.5 second to load #88

Open
yermulnik opened this issue Jul 9, 2024 · 7 comments
Open
Labels
bug Something isn't working needs-triage needs to be reviewed

Comments

@yermulnik
Copy link

yermulnik commented Jul 9, 2024

What happened?

What did you do? What happened? What did you expect to happen?

eval "$(gh copilot alias -- bash)" took 0.5 sec to load (I'm the "User is not authorized to use this Copilot feature"). I'd expect it to load much faster as 0.5 sec is a way too slow.

Versions

What versions of the relevant software are you running?
For example: gh v2.37.0, gh-copilot v0.5.2-beta

  • gh version 2.52.0 (2024-06-24)
  • version 1.0.3 (2024-05-08)

Relevant terminal output

Please copy and paste any relevant terminal output.
Please check your output before submission to ensure sensitive information is redacted.

> time eval "$(gh copilot alias -- bash)"

real    0m0,611s
user    0m0,210s
sys     0m0,053s

and another workstation:

> time eval "$(gh copilot alias -- bash)"

real    0m0,548s
user    0m0,156s
sys     0m0,037s

Ubuntu and Mint if it matters.

@yermulnik yermulnik added bug Something isn't working needs-triage needs to be reviewed labels Jul 9, 2024
@jarrodldavis
Copy link

I have the same issue using eval "$(gh copilot alias -- zsh)" on macOS. Strangely, the entire script to be evaluated is emitted instantly, it's just that the gh command takes a long time to exit.

@BagToad
Copy link
Member

BagToad commented Nov 20, 2024

I suspect this actually has more to do with gh startup time than the gh-copilot extension - see cli/cli#9724

@yermulnik @jarrodldavis, could you try setting TCELL_MINIMIZE=1 and let us know if that improves the performance?

@jarrodldavis
Copy link

@BagToad That helped performance a bit, but only reduced from 0.11s to 0.07s (according to time). As I noted initially, the issue is after the script is emitted, suggesting that it's an issue with the exit time, not the startup time. Additionally, I notice this slow exit consistently across all gh copilot commands (even gh copilot --help), but the root gh command is fast.

@yermulnik
Copy link
Author

> export TCELL_MINIMIZE=1
> time eval "$(gh copilot alias -- bash)"

real    0m1,250s
user    0m0,167s
sys     0m0,080s

# second run
> time eval "$(gh copilot alias -- bash)"

real    0m1,116s
user    0m0,120s
sys     0m0,037s

🤔

@BagToad
Copy link
Member

BagToad commented Nov 20, 2024

Ah, thanks for trying that out! Sounds like we have more investigating to do 😁

@pmeheut
Copy link

pmeheut commented Jan 16, 2025

Same problem here and even slower in my good old Macpro: 1.7 sec. Ok, it is only a 12 core 3.3 Ghz Xeon but still: nothing it that slow.

In the meantime, I've decided to cache it each day, commenting the line out and adding this to my .bashrc:

# Define the path to the .ghrc file
GHRC_PATH="$HOME/.ghrc"

# Check if the file exists and is older than 1 day
if [[ ! -f "$GHRC_PATH" || $(find "$GHRC_PATH" -mtime +0 -print) ]]; then
  echo "Updating .ghrc file..."
  gh copilot alias -- bash > "$GHRC_PATH"
fi

# Evaluate the content of the .ghrc file
if [[ -f "$GHRC_PATH" ]]; then
  echo "Evaluating .ghrc file..."
  source "$GHRC_PATH"
else
  echo "Error: .ghrc file not found after update."
  exit 1
fi

@GriwMF
Copy link

GriwMF commented Jan 18, 2025

Have the same issue with bash in Arch under wsl

~ $ time eval "$(gh copilot alias -- bash)"

real    0m1.267s
user    0m0.052s
sys     0m0.040s
~ $ export TCELL_MINIMIZE=1
~ $ time eval "$(gh copilot alias -- bash)"

real    0m1.253s
user    0m0.075s
sys     0m0.028s
~ $

As a temporary fix I did
gh copilot alias -- bash > .bash_copilot_aliases
and then loaded it in my .bashrc

# load .bash_copilot_aliases if it exists
if [ -f ~/.bash_copilot_aliases ]; then
    . ~/.bash_copilot_aliases
fi

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

No branches or pull requests

5 participants