Allow dependencies initialise in parallel #96
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related #22
This PR enhances the sorting strategy by grouping keys based on the depth of nodes. So instead of attempting to sequentially invoke initializing function for each element in topologically sorted nodes - perform the same for batches of keys grouped by their position in the graph.
For example, consider the following graph:
Before this PR integrant will try to build the system from this sequence:
(E F B C D A)
. So if some node is taking some time to finish initialization it will block subsequent initialization attempts. With this PR the same sequence will have additional grouping:((E F C D) (B) (A))
giving the opportunity to parallelise the initialisation step for the keys in the same group.Here is a made-up example to illustrate the benefits:
Normally such a system will take at least 4 seconds to build because each initialisation function must finish before attempting to initialise the next node.
Those adjustments will be visible only in Clojure because the current implementation relies on
clojure.core/future
function which is missing in ClojureScript but probably it is possible to adjust it later.List of difficulties to take care of (from comment):