Code Monkey home page Code Monkey logo

Comments (7)

weavejester avatar weavejester commented on May 9, 2024

In theory that possible, but it would take a bit of work to achieve. Right now the components are sorted and started serially; we'd need a more sophisticated system to figure out which could be started in parallel.

from integrant.

hmaurer avatar hmaurer commented on May 9, 2024

@weavejester how sophisticated would this be? I assume you would need to model the dependency as a directed acyclic graph, then traverse it, starting from nodes with no incoming edges, and at each step loading all selected nodes in parallel? Or am I missing something?

from integrant.

danielcompton avatar danielcompton commented on May 9, 2024

You'd also need to handle threading, Integrant might need to provide a thread pool, or let the user provide one. It seems possible, but would need some thought to keep it easy for the user.

from integrant.

weavejester avatar weavejester commented on May 9, 2024

The dependencies are already modelled as a graph, which can be retrieved with the dependency-graph function. However, there are a few difficulties around initiating concurrently:

  1. The order of components starting is no longer deterministic
  2. We need to build our own iteration mechanism
  3. We need to keep a list of all dependencies that have begun to be initiated, as we can run into the same dependency multiple times even if the graph is acyclic
  4. We need to halt all threads on an exception, and return the exception
  5. We might need some manner of thread pool
  6. Certain keys will take a very short time to initiate; these may actually be slower with the thread overhead
  7. Maybe other things I haven't thought of

from integrant.

deoqc avatar deoqc commented on May 9, 2024

From Erlang Programming Rules:

3.12 Make code as deterministic as possible

For example, suppose one process has to start five parallel processes and then check that they have started correctly, suppose further that the order in which these five are started does not matter.

We could then choose to either start all five in parallel and then check that they have all started correctly but it would be better to start them one at a time and check that each one has started correctly before starting the next one.

Well, probably the default should be start serially.

Only if is really needed, it could explicitly be asked to start something in parallel.

from integrant.

serioga avatar serioga commented on May 9, 2024

My solution for this problem https://gist.github.com/serioga/1c2f5a6ef771a267a6e726a066e2bf39

from integrant.

serioga avatar serioga commented on May 9, 2024

Parallel initialization addon for integrant https://github.com/serioga/webapp-clojure-2020/blob/master/src/lib/integrant/async.clj

from integrant.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.