cafehaine / xontrib-xlsd

xontrib-xlsd is the next gen ls command for xonsh shell, inspired by lsd.
GNU General Public License v3.0
21 stars 4 forks source link

some speedups to importing #29

Closed scopatz closed 3 years ago

scopatz commented 3 years ago

This PR adds a lot of lazy loading features. It attempts to make the xontrib load xlsd operation faster.

Without this line in my xonshrc, I see:

scopatz@artemis:~$ xonsh --timings --shell-type=rl
 Debug level: Off
|----------------------|-----------|-----------|
|Event name            | Time (s)  | Delta (s) |
|----------------------|-----------|-----------|
|start                 |   0.000   |   0.000   |
|pre_execer_init       |   0.012   |   0.012   |
|post_execer_init      |   0.048   |   0.036   |
|on_pre_rc             |   0.048   |   0.000   |
|on_post_rc            |   0.171   |   0.123   |
|on_post_init          |   0.182   |   0.010   |
|on_pre_cmdloop        |   0.182   |   0.000   |
|on_pre_prompt_format  |   0.182   |   0.000   |
|on_pre_prompt         |   0.188   |   0.006   |
|----------------------|-----------|-----------|

With xontrib load xlsd in my xonshrc, but on current master, I see

scopatz@artemis:~$ xonsh --timings --shell-type=rl
 Debug level: Off
|----------------------|-----------|-----------|
|Event name            | Time (s)  | Delta (s) |
|----------------------|-----------|-----------|
|start                 |   0.000   |   0.000   |
|pre_execer_init       |   0.012   |   0.012   |
|post_execer_init      |   0.051   |   0.038   |
|on_pre_rc             |   0.051   |   0.000   |
|on_post_rc            |   0.461   |   0.410   |
|on_post_init          |   0.467   |   0.007   |
|on_pre_cmdloop        |   0.468   |   0.000   |
|on_pre_prompt_format  |   0.468   |   0.000   |
|on_pre_prompt         |   0.472   |   0.004   |
|----------------------|-----------|-----------|

With the line in my xonshrc and on this branch, I see:

scopatz@artemis:~$ xonsh --timings --shell-type=rl
 Debug level: Off
|----------------------|-----------|-----------|
|Event name            | Time (s)  | Delta (s) |
|----------------------|-----------|-----------|
|start                 |   0.000   |   0.000   |
|pre_execer_init       |   0.012   |   0.012   |
|post_execer_init      |   0.047   |   0.035   |
|on_pre_rc             |   0.047   |   0.000   |
|on_post_rc            |   0.361   |   0.314   |
|on_post_init          |   0.370   |   0.009   |
|on_pre_cmdloop        |   0.370   |   0.000   |
|on_pre_prompt_format  |   0.370   |   0.000   |
|on_pre_prompt         |   0.376   |   0.005   |
|----------------------|-----------|-----------|

So this is about 100 ms better. There are still about 200 ms to go. This may be a xonsh issue/bug though, because I am not sure what else could be avoided here.

cafehaine commented 3 years ago

I'll check this out tomorrow, thanks for the PR!

scopatz commented 3 years ago

Thanks, no rush!

cafehaine commented 3 years ago

Looks good to me, thanks!

Also thanks for the env registering part ^^

scopatz commented 3 years ago

thanks for merging!