immoh / lively

ClojureScript live coding with ease
46 stars 0 forks source link

Slow parsing of dependencies on current CLJS versions (0.0-2755, 0.0-2850) #1

Closed viesti closed 9 years ago

viesti commented 9 years ago

First of all, thanks for a library that I and some of my colleagues use daily :)

Then the problem. Current CLJS versions seem to contain lot of items in goog._dependencies.nameToPath (5314 on a fresh project created from the mies template). Seems that lively chokes on handling this amount in get-js-files-in-dependency-order function.

There seems to be quite alot of i18n related items that I haven't seen earlier, see this gist: https://gist.github.com/viesti/25c3ac5920150c596957

Quick debugger pausing would seem to show that the call stack spends time in calls to set from topo-sort which leads to creating hashes for the items in the set: callstack

immoh commented 9 years ago

Cool to hear that somebody's actually using lively :)

It appears that the number of JS dependencies in ClojureScript runtime (goog.dependencies_) has increased quite dramatically: from 0.0-2655 to 0.0-2719 it went from 13 to 5306. Since lively is never reloading goog.* namespaces, it doesn't actually need to sort these, or request the headers of corresponding JS files. By looking at the code it seems that it is doing this when populating cache in the beginning.

I'm sure topo-sort could be optimized as well but if I'm not mistaken the real bottleneck is the amount of dependencies to handle.

viesti commented 9 years ago

Yep, so filtering out goog.* (and maybe cljs.*, but goog.* is the monster) from the dependencies would make life easier :) Just wondering that does figwheel have something like this, I haven't actually used it....

immoh commented 9 years ago

https://github.com/clojure/clojurescript/commit/e726c22fcc77bfd38cc17a2f0d8349c43c83add5

It seems that all goog.* deps are now loaded by default, so basically lively could ignore them completely. Also no need to reload goog/deps.js since it doesn't change.. Earlier it was possible that new goog.* dependencies were introduced by user and lively took care of loading them.

immoh commented 9 years ago

Hasty conclusions, new goog.* deps need to be loaded, lively just doesn't need to poll for changes in them.

viesti commented 9 years ago

Ah, true.

immoh commented 9 years ago

Deployed 0.1.3-SNAPSHOT to Clojars with fix for this. Feedback very much appreciated.

viesti commented 9 years ago

Thanks! Will try to find time for this :)

viesti commented 9 years ago

Tried out on my project and on a clean lein mies template (0.0-2755 and 0.0-2850 CLJS versions) and seems that lively doesn't hang any longer. So seems that the fix works :)

immoh commented 9 years ago

Pushed this out as 0.2.0 together with breaking change to fix single segment namespace issue.