jrmoulton / tmux-sessionizer

Tmux Sessionizer: A tool for opening git repositories as tmux sessions
MIT License
458 stars 35 forks source link

Slow loading when path subdirectory doesn't have git initialized #126

Open arielcorte opened 1 month ago

arielcorte commented 1 month ago

After I installed the tool and configured the path to my coding directory, loading the sessions took a few seconds.

I started to indagate into the problem, by copying one by one the subdirectories to another path. I found that when I added a subdirectory without an initialized git repo, the time was increased by a few seconds (instead of milliseconds).

I tried configuring --max-depths 1 with no noticeable effect.

The workaround that solved the loading time for me was to make a script to run git init in each subdirectory.

jrmoulton commented 1 month ago

I'm not sure what is going on in your specific case. I have subdirectories without initialized git repos and don't have any delay. Do you have any other specific information?

arielcorte commented 1 month ago

I don't know what info might help you here.

I have my coding directory with 107 repos (the one I initialized git in all of them) and works faster than a test directory in which I added 3 non initialized git subdirectories.

➜  ~ tms config -p coding 
Configuration has been stored
➜  ~ time tms
tms  0.02s user 0.08s system 13% cpu 0.695 total
➜  ~ tms config -p tms_test 
Configuration has been stored
➜  ~ time tms
tms  0.03s user 0.21s system 28% cpu 0.830 total
➜  ~ ls tms_test 
no-git2  non-git  not-git
➜  ~ ls tms_test/not-git 
➜  ~ ls tms_test/non-git 
112A_cf.cpp    1630_cses.cpp  1661_cses.cpp  1955B_cf.cpp  2004A_cf.cpp  230A_cf.cpp  2428_cses_copy.cpp  codeforces  cses              template.cpp
1399A_cf.cpp   1643_cses.cpp  1662_cses.cpp  1956A_cf.cpp  2004B_cf.cpp  231A.py      2428_cses.cpp       contest1    glistering_melon  test_template.cpp
1629_cses.cpp  1660_cses.cpp  166A_cf.cpp    1956B_cf.cpp  2004C_cf.cpp  231.cpp      a.out               contest2    printing          tmp.cpp
➜  ~ cd coding/
zsh: do you wish to see all 107 possibilities (22 lines)? 

coding directory with 107 subdirectories:

➜  ~ tms config -p coding 
Configuration has been stored
➜  ~ time tms
tms  0.02s user 0.08s system 15% cpu 0.619 total
➜  ~ time tms
tms  0.02s user 0.08s system 18% cpu 0.531 total
➜  ~ time tms
tms  0.02s user 0.08s system 21% cpu 0.442 total

tms_test directory with 3 non initialized git directories:

➜  ~ tms config -p tms_test 
Configuration has been stored
➜  ~ time tms
tms  0.03s user 0.21s system 30% cpu 0.782 total
➜  ~ time tms
tms  0.03s user 0.21s system 32% cpu 0.742 total
➜  ~ time tms
tms  0.02s user 0.22s system 29% cpu 0.814 total

I think it is important to also note that the subdirectories of tms_test are directly copied from coding but removed the .git repository

arielcorte commented 1 month ago

I've also noticed that python directories are also causing a bit of a delay with its .venv. Here's the time of tms after deleting it from tms_test/no-git2/deep_learning/.venv:

➜  ~ tms config -p tms_test
Configuration has been stored
➜  ~ time tms
tms  0.03s user 0.15s system 24% cpu 0.712 total
➜  ~ time tms
tms  0.02s user 0.15s system 25% cpu 0.676 total
➜  ~ time tms
tms  0.02s user 0.15s system 27% cpu 0.623 total

which is still greater than the coding directory

arielcorte commented 1 month ago

After deleting the other python venv directory in tms_test/non-git/.../venv, the times make more sense:

➜  ~ tms config -p tms_test
Configuration has been stored
➜  ~ time tms
tms  0.01s user 0.02s system 2% cpu 0.870 total
➜  ~ time tms
tms  0.01s user 0.01s system 7% cpu 0.328 total
➜  ~ time tms
tms  0.01s user 0.01s system 3% cpu 0.638 total

All the tests were done with --max-depth = 1 so shouldn't tms skip the venv directories?