gforsyth / xonda

DEPRECATED: (previously a thin wrapper around conda for xonsh)
BSD 3-Clause "New" or "Revised" License
11 stars 9 forks source link

Loading xontrib is slow #23

Closed danmou closed 6 years ago

danmou commented 6 years ago

Adding xontrib load xonda to my .xonshrc adds around 0.4s to the xonsh startup time on my pc (which is more than a doubling when xonsh is run as a background process). Is there any way to speed this up? Could lazyasd somehow be used to delay loading of whatever is causing the delay until it is actually needed?

gforsyth commented 6 years ago

Hey @Danmou -- thanks for reporting! Yeah, I hadn't really noticed but there is a measurable delay.

Could you try running these commands and posting your output? On my end if looks like the conda.install import is the culprit, but it would be good to confirm.

In [1]: %time import conda.install
CPU times: user 168 ms, sys: 23 ms, total: 191 ms
Wall time: 191 ms

In [2]: %time import os
CPU times: user 4 µs, sys: 0 ns, total: 4 µs
Wall time: 5.96 µs

In [3]: %time from conda import config
CPU times: user 4.95 ms, sys: 633 µs, total: 5.58 ms
Wall time: 5.19 ms

In [4]: %time from collections import namedtuple
CPU times: user 9 µs, sys: 1 µs, total: 10 µs
Wall time: 13.1 µs
gforsyth commented 6 years ago

Hey @Danmou -- I wrapped lazyasd around the conda imports on my local laptop and I'm seeing a significant speedup. I'll push up those changes and cut a new release tonight. Thanks again for bringing this to my attention!

danmou commented 6 years ago

Hey @gforsyth, thanks for the quick fix! From my testing it seems that both conda.install and conda.config take a significant amount of time, if they are imported first -- the one that is imported second is fast. So wrapping them both with lazyasd should work. I will test the new release when it is out.

gforsyth commented 6 years ago

Hey @Danmou -- new release is coming, but if you want to pull from master and reinstall you should find startup time is much faster.

danmou commented 6 years ago

It works, thanks again :)

gforsyth commented 6 years ago

New release is out on pypi and conda-forge