bhauman / rebel-readline

Terminal readline library for Clojure dialects
Eclipse Public License 1.0
680 stars 37 forks source link

Defer loading of cljfmt and compliment to improve startup time #155

Closed alexander-yakushev closed 6 years ago

alexander-yakushev commented 6 years ago

For context, see #154.

As promised, I've made cljfmt loading lazy. While at it, I also deferred Compliment loading which was a much smaller issue but still brought some weight. The results on my local setup are:

Since this is not the first time I implement lazy-loading functionality in a project, I've decided to extract it into a library. I know you don't want to add many dependencies to rebel-readline (which slows down the start, that's the whole point), but this one is just a few functions and surely will never have any dependencies on its own. Here it is: https://github.com/clojure-goes-fast/lazy-require

So, cljfmt and Compliment are required lazily now. However, they are actually being loaded in the background, so if the user trigger indentation/completion in the first 2-3 seconds, they won't experience the deferred loading lag. (If that becomes an issue with completion, we can always put Compliment back on the eager list. It doesn't add more than 300ms).

Please, tell me what you think. I'll be happy to iterate.

bhauman commented 6 years ago

I've read your patches and I'm inclined to implement this directly.

IE. require-resolve the needed vars and load them in the background on start.

Really not wanting extra deps, and there isn't a need for a lazy load framework IMHO.

And I'm really going to be getting rid of cljfmt in the future so this will be reverted.

I really appreciate your work on this, but I'm thinking the simpler method will work just fine.

bhauman commented 6 years ago

BTW I'm really digging your blog :) Nice work 👍

alexander-yakushev commented 6 years ago

No problem, I totally understand you want to keep the dependencies at a minimum and I'd rather you keep doing that.

I'll keep this open as a reference until you implement the necessary bits.

Glad you like the blog :)

bhauman commented 6 years ago

Thanks for the excellent profiling now to test out rebel-readline-cljs