Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delayed initialization of features for better startup time #21

Closed
ikitommi opened this issue Feb 21, 2015 · 5 comments
Closed

delayed initialization of features for better startup time #21

ikitommi opened this issue Feb 21, 2015 · 5 comments

Comments

@ikitommi
Copy link
Contributor

love the features, but with my i7 mac book pro, it add's about 1.5sec to initialize the plugin when running any lein-related command. Would it be possible to delay initialization of the features so that it woudn't cause delays when running non-ultra related tasks such as lein uberjar?

without ultra (with lots of other plugins & tunings):

$ time lein run -m clojure.main/main -e "(+ 1 1)"
2
lein run -m clojure.main/main -e "(+ 1 1)"  3.12s user 0.21s system 144% cpu 2.304 total

adding ultra:

$ time lein run -m clojure.main/main -e "(+ 1 1)"
2
lein run -m clojure.main/main -e "(+ 1 1)"  4.62s user 0.26s system 131% cpu 3.722 total

... having totally empty .lein/profiles.clj gives even worse figures:

without:

$ time lein run -m clojure.main/main -e "(+ 1 1)"
2
lein run -m clojure.main/main -e "(+ 1 1)"  1.30s user 0.10s system 134% cpu 1.044 total

with ultra as the only plugin:

$ time lein run -m clojure.main/main -e "(+ 1 1)"
2
lein run -m clojure.main/main -e "(+ 1 1)"  3.38s user 0.18s system 132% cpu 2.682 total
@venantius
Copy link
Owner

You're not the first person to have asked for this.

I did a bit of profiling myself - Ultra adds about 0.3-0.4s worth of dependencies, and then require-ing th e core ultra ns immediately adds about 2-2.5s on my laptop - even if we don't actually do any "work" in that ns. After a bit of further profiling it seems to boil down to the general cost of namespace loading in Ultra. One option would be to move to a more dynamic namespace loading model, so that if a given feature isn't enabled in the project map then its respective namespace and dependencies aren't loaded.

All of the benefits there would still be predicated on your project map being set up with features disabled, though - otherwise you're still following the ultimate code paths, just in a different order. The plugin uses Leiningen middleware so it would be potentially ugly to selectively enable it only for certain lein tasks (the naive implementation that occurs to me off the top of my head would be some sort of project map manipulation disabling certain features for respective tasks; the REPL middleware when testing or building an uberjar, e.g.).

I also don't know if there's a way of lazily loading features as they're needed, or whether just pushing the activation to separate threads would do the trick - I don't have the greatest insight into Leiningen's startup process.

Thoughts?

@ikitommi
Copy link
Contributor Author

ikitommi commented Mar 2, 2015

hi, sorry for not answering, got buried under everything else, thanks for the response and the resolution! Will continue to be a happy Ultra user :)

Tommi

@venantius
Copy link
Owner

Yeah, I think I may have accidentally screwed up the test configuration path unfortunately. The REPL stuff definitely still works but it looks like there's going to have to be an imminent 0.3.1 release to figure out a proper way of initializing tests.

@ikitommi
Copy link
Contributor Author

ikitommi commented Mar 2, 2015

$ time lein run -m clojure.main/main -e "(+ 1 1)"
2
lein run -m clojure.main/main -e "(+ 1 1)"  3.52s user 0.23s system 140% cpu 2.667 total

so it dropped from 3.7sec to 2.6sec --> more than 1sec off the load time (now just 0.2sec extra on my mac). Great work!!

cheers,

Tommi

@venantius
Copy link
Owner

high five

Related/unrelated: I recommend upgrading to 0.3.2 when you get a chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants