scopatz / xo

exofrills text editor
http://exofrills.org/
Do What The F*ck You Want To Public License
99 stars 16 forks source link

Takes a long time to start #15

Closed certik closed 6 years ago

certik commented 8 years ago

I did a test, when I open a file, and then close it as quickly as I can using CTRL-X, and measure how long it takes (closing is immediate, the startup time is long):

certik@redhawk:~/repos/xo(master)$ time xx/bin/xo xo.py 
real    0m1.895s
user    0m1.044s
sys 0m0.048s
certik@redhawk:~/repos/xo(master)$ time xx/bin/xo xo.py 

real    0m1.359s
user    0m1.040s
sys 0m0.036s
certik@redhawk:~/repos/xo(master)$ time xx/bin/xo xo.py 

real    0m1.426s
user    0m1.056s
sys 0m0.040s
certik@redhawk:~/repos/xo(master)$ time xx/bin/xo xo.py 

real    0m1.418s
user    0m1.020s
sys 0m0.052s
certik@redhawk:~/repos/xo(master)$ time xx/bin/xo xo.py 

real    0m1.408s
user    0m1.044s
sys 0m0.036s
certik@redhawk:~/repos/xo(master)$ time xx/bin/xo xo.py 

real    0m1.421s
user    0m1.048s
sys 0m0.028s
certik@redhawk:~/repos/xo(master)$ time xx/bin/xo xo.py 

real    0m1.281s
user    0m1.068s
sys 0m0.040s
certik@redhawk:~/repos/xo(master)$ time xx/bin/xo xo.py 

real    0m1.362s
user    0m1.036s
sys 0m0.040s
certik@redhawk:~/repos/xo(master)$ time xx/bin/xo xo.py 

real    0m1.442s
user    0m1.036s
sys 0m0.068s

The best time is 1.281s. Compare to Vim:

certik@redhawk:~/repos/xo(master)$ time vim xo.py 

real    0m0.386s
user    0m0.088s
sys 0m0.008s
certik@redhawk:~/repos/xo(master)$ time vim xo.py 

real    0m0.282s
user    0m0.084s
sys 0m0.008s
certik@redhawk:~/repos/xo(master)$ time vim xo.py 

real    0m0.354s
user    0m0.068s
sys 0m0.012s
certik@redhawk:~/repos/xo(master)$ time vim xo.py 

real    0m0.328s
user    0m0.092s
sys 0m0.004s

Best time 0.282s, and I have to press ZZ, which is slower than CTRL+X.

Conclusion: xo takes 1s more to start than vim on my machine. Vim is immediate (the 0.2s is the time it takes me to pres ZZ), while xo literally takes a second to start.

scopatz commented 8 years ago

Thanks for reporting! I get start up times on the order of 0.5 sec. Still I think one thing that I'll probably do is add an alias / xontrib so that starting up from xonsh is much faster.

scopatz commented 8 years ago

Ok, I have added a xontrib which more or less takes care of this for me, since xo xo.py will now execute in about 0.27 - 0.36 seconds for me.

rovitotv commented 6 years ago

I just use bash for my shell...can we do something else to speed up startup? I was reading about python and startup issues https://files.bemusement.org/talks/OSDC2008-FastPython/ which makes several recommendations. I was able to speed up xo startup with lazy regular expressions. I was thinking about playing with lazy imports. Would you be interested in a PR for lazy imports and lazy re?

scopatz commented 6 years ago

Hi @rovitotv - always happy to have PRs! However, note that the fundamental problem with the slow startup times is pygments, which relies on pkg_resources to find Lexers for the files we are reading in. I have an idea about how to cache these in such a way that would speed up load times dramatically. (I also need this for xonsh), but I haven't gotten around to writing it yet.

rovitotv commented 6 years ago

With the latest release exofrills 0.3.0 xo is a lot faster on startup, thank you! pygments-cache seems to have done the trick.

scopatz commented 6 years ago

Woohoo! That is great to hear! I am going to go ahead and close this issue, but please feel free to reopen if needed!

rovitotv commented 6 years ago

👍