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

The popup feels slow #123

Open
praveshishere opened this issue Jun 29, 2024 · 19 comments
Open

The popup feels slow #123

praveshishere opened this issue Jun 29, 2024 · 19 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@praveshishere
Copy link

I am not sure if this is an issue, or is expected

but there is a delay, before the popup opens and, there is a delay when I navigate between sessions,
I disabled the preview still the same.

@alexanderfast
Copy link

Joining this issue since I experience the same thing. The one second delay before i can start typing is rather jarring compared to other plugins that do the same thing (dump session list to fzf).

It feels like something traversing a directory tree when it shouldnt, so I disabled the custom paths setting, in addition to the preview. Though I'm not entirely sure how I would go about profiling the bash scripts when run inside tmux.

set -g @sessionx-preview-enabled 'false'
set -g @sessionx-custom-paths-subdirectories 'false'

@praveshishere
Copy link
Author

Joining this issue since I experience the same thing. The one second delay before i can start typing is rather jarring compared to other plugins that do the same thing (dump session list to fzf).

It feels like something traversing a directory tree when it shouldnt, so I disabled the custom paths setting, in addition to the preview. Though I'm not entirely sure how I would go about profiling the bash scripts when run inside tmux.

set -g @sessionx-preview-enabled 'false'
set -g @sessionx-custom-paths-subdirectories 'false'

I don't exactly understand the traversing part, but the config does not help make it any faster

@omerxx
Copy link
Owner

omerxx commented Sep 23, 2024

Hi folks, is there any update on this? Are you still feeling slowness?
Stating the obvious but - can you try with latest Tmux + FZF + vanilla sessoinx config and see whether it persists?

@omerxx omerxx added the help wanted Extra attention is needed label Sep 23, 2024
@LoricAndre
Copy link

I'm seeing it too, modifying the tmux_option_or_fallback calls to use the defaults earned me around 0.2 seconds. Would it be possible to expand those variables in the .tmux file and pass them to the script invocation in the keybind directly ? This would only run those calls once, instead of at every keybind.

@LoricAndre
Copy link

I tried my hand at a refactor to implement this in #152

@raymccarthy
Copy link

I have discovered three things, but I am not sure of the significance.

  1. The plugin is lighting fast on my ubuntu dev macine
  2. It takes nearly 3 seconds to open on my ARM MacBook running Macos Sequoia
  3. It opens in less than half a second when I run the script directly on the command line of the Mac, without using the tmux key binding

So my conclusion is that the issue is in the tmux keybinding logic.

@ahmedYasserM
Copy link

Same thing here on Linux void 6.6.56_2, it takes about 1 second to open

@omerxx
Copy link
Owner

omerxx commented Oct 21, 2024

Hi everyone, i've pushed this today, inspired by #152 , can you please update and let me know whether the situations slightly improves?

@Marat-Gumerov
Copy link
Contributor

Marat-Gumerov commented Oct 22, 2024

I've updated the plugin a few minutes ago. It seems like it takes 630 ms for the popup to open. I think it is very good, but I still want better :)

@Marat-Gumerov
Copy link
Contributor

Marat-Gumerov commented Oct 22, 2024

The slowest thing I found in the logs is the tmux_option_or_fallback call, which takes around 8-9 ms. This function is called 42 times before the popup appears, so it takes around 350 ms total. For example, the call tmux_option_or_fallback @sessionx-bind-zo-new-window ctrl-f took 9 ms:

++ 1729574376.197823826  tmux_option_or_fallback @sessionx-bind-zo-new-window ctrl-f
++ 1729574376.198778377  local option_value
+++ 1729574376.199899770         tmux show-option -gqv @sessionx-bind-zo-new-window
++ 1729574376.203769773  option_value=
++ 1729574376.205028227  '[' -z '' ']'
++ 1729574376.205988512  option_value=ctrl-f
++ 1729574376.206872481  echo ctrl-f

@Marat-Gumerov
Copy link
Contributor

I've replaced all tmux_option_or_fallback calls by values I prefer (or default ones). Now it takes only 213 ms for the popup to open. I think this plugin should have much less options or have a faster way to read them.

@omerxx
Copy link
Owner

omerxx commented Oct 22, 2024

@Marat-Gumerov interesting!! Thanks!
BTW - what did you use for the timings?

@Marat-Gumerov
Copy link
Contributor

Marat-Gumerov commented Oct 22, 2024

PS4='+ $(date "+%s.%N")\011 ' bash -x scripts/sessionx.sh

That's what ChatGPT suggested me to use

@omerxx omerxx self-assigned this Oct 22, 2024
@omerxx omerxx mentioned this issue Oct 22, 2024
@omerxx
Copy link
Owner

omerxx commented Oct 22, 2024

@Marat-Gumerov care to give this version a try?
#154

I added caching to the parameters, should work quicker.
currently using a 5 min ttl, can be changed later

@Marat-Gumerov
Copy link
Contributor

Marat-Gumerov commented Oct 23, 2024

@omerxx, well, it seems a little bit worse than it was before. Sorry :(
Now it takes 645 ms with cache and 1090 ms without it.
Reading cache from file takes 146 ms.
tmux_option_or_fallback calls take 7-8 ms:

++ 1729679955.212351807  tmux_option_or_fallback @sessionx-tree-mode off
++ 1729679955.213401232  local option=@sessionx-tree-mode
++ 1729679955.214518419  local default=off
++ 1729679955.216097107  [[ -n x ]]
++ 1729679955.217340938  [[ -z '' ]]
++ 1729679955.218316582  echo off
++ 1729679955.219322282  return

So I still need 440 ms to read options in the best case.

Why don't you use the approach from #152? It seems like all this option reading stuff is handled during the sessionx.tmux file execution, so we don't have to execute it every single time we open the window. Isn't it better for performance?

Unfortunately, I can't test the #152 version right now so I don't know how fast it is :(

BTW, #152 breaks tmuxinator support right now.

@omerxx
Copy link
Owner

omerxx commented Oct 23, 2024

152 is not bad it just breaks a few things ATM, so I'm waiting for updates

@Marat-Gumerov
Copy link
Contributor

I've found out how to test #152:

  • Add the following lines to the end of the sessionx.tmux file:
export PS4='+ $(date "+%s.%N")\011 '
bash -x scripts/sessionx.sh "$(build_args) $(build_fzf_opts)"
  • Run:
./sessionx.tmux

Now it takes around 215 ms on my machine.

@Marat-Gumerov
Copy link
Contributor

@omerxx, I decided to implement my version, inspired by ideas from #152, thanks to @LoricAndre

Please take a look at #155

I hope this implementation does not break anything. BTW, I tested it with tmuxinator and it seems to be working as expected.

@Marat-Gumerov
Copy link
Contributor

I feel like someone is busy rewriting this plugin from scratch using Nushell :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants