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

Help users diagnose slow prompts #10

Open
kovasap opened this issue Apr 13, 2020 · 4 comments
Open

Help users diagnose slow prompts #10

kovasap opened this issue Apr 13, 2020 · 4 comments

Comments

@kovasap
Copy link

kovasap commented Apr 13, 2020

Do you have any tips/tricks when it comes to determining what parts of prompt.gem are causing a lag in generating the next prompt? I'm hoping to find some kind of general bash profiler that can pin down slow code.

Thanks!

@dimo414 dimo414 transferred this issue from dimo414/ProfileGem Apr 13, 2020
@dimo414
Copy link
Owner

dimo414 commented Apr 13, 2020

Thanks for the question; this is something I've wanted to make easier for end-users to investigate, but at the moment it's a bit manual. There are some tools / hooks you can experiment with, however.

  • _PGEM_DEBUG=true pgem_reload prints a bunch of diagnostic information, including how long prompt-generation took to execute; you can also directly invoke _prompt_command
  • The functions listed in "${COMMAND_FINISHED_CALLBACKS[@]}" and "${ENV_INFO[@]}" are invoked on each prompt, so you can time those functions individually and see if anything stands out
  • Expensive ENV_INFO functions are usually cached using bash-cache, which saves redundant computations. You can use bc::benchmark SOME_FUNCTION to see timing data for a function with and without caching to determine whether caching is appropriate
  • I haven't used it personally, but there is a Bash debugger you could look into

@dimo414 dimo414 changed the title Profiling a slow prompt Help users diagnose slow prompts Apr 13, 2020
@dimo414
Copy link
Owner

dimo414 commented May 20, 2020

Some useful profiling strategies: https://stackoverflow.com/q/5014823/113632

@kovasap
Copy link
Author

kovasap commented May 20, 2020

Thanks for the updates! I've been playing around with a zsh environment right now so I haven't had a chance to try this.

@dimo414
Copy link
Owner

dimo414 commented May 20, 2020

No worries, this is mostly for my reference - though obviously user feedback is welcome. If there's anything different or more useful about your zsh environment (other than being zsh, obviously) that feedback would also be insightful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants