Code Monkey home page Code Monkey logo

Comments (11)

jzabroski avatar jzabroski commented on August 23, 2024 1

Ok, feeling dumb

My thought was that , as an end user of your library, I may want to "bring my own threading model" so that you don't have to guess as to whether I have concurrent dependencies.

This main problem is to decide what lambdas are not needed.

I was not looking at the problem from this perspective. I was just thinking, how can we remove concurrency altogether.

I will try to assign scoped or any the same expressions into variable and use them in glabal global Expression.Block.

If I understand you, you're doing a compiler writer trick called Single Static Assignment. Effectively, every node in an expression tree is assigned to once, which makes constant folding analysis easier. The big win behind SSA form is it's trivial to determine constant fold opportunities, because every value in the tree is a constant, so you're literally just looking for duplicates to "lift" up to the top of the tree, thereby reducing memory allocations.

from dryioc.

dadhi avatar dadhi commented on August 23, 2024

This issue may help with #27

from dryioc.

dadhi avatar dadhi commented on August 23, 2024

Did some related work in #1

from dryioc.

jzabroski avatar jzabroski commented on August 23, 2024

Isn't the point of TheadLocal<T> so that you don't use Lazy<T> if you know you need state on a specific thread?

I guess there is a narrow use case where you might want to share the T in Lazy across threads, but that seems like a bad idea.

from dryioc.

jzabroski avatar jzabroski commented on August 23, 2024

Another option is to allow the Registrar to specify the LazyThreadSafetyModeview=netframework-4.7.2 or to build an expression tree for LazyInitialier.EnsureInitialized which builds the computation graph. Right?

from dryioc.

dadhi avatar dadhi commented on August 23, 2024

I am not sure I am following you.
The whole goal is to simplify object graph by removing (not needed?) nested lambdas which prolongs compilation and interpretation times.
This main problem is to decide what lambdas are not needed.

Btw, I am not renaming IRegistrator to IRegistrar. It is too much of breaking change for almost no value.

from dryioc.

dadhi avatar dadhi commented on August 23, 2024

Ok, feeling dumb but I will try to assign scoped or any the same expressions into variable and use them in global Expression.Block.
For interpretation I will memoize the results of the same expressions, maybe excluding Constant, Convert and other UnaryExpressions.

from dryioc.

dadhi avatar dadhi commented on August 23, 2024

If I understand you, you're doing a compiler writer trick called Single Static Assignment. Effectively, every node in an expression tree is assigned to once, which makes constant folding analysis easier. The big win behind SSA form is it's trivial to determine constant fold opportunities, because every value in the tree is a constant, so you're literally just looking for duplicates to "lift" up to the top of the tree, thereby reducing memory allocations.

Yes, it fits. So much of cool stuff to learn :)
The idea is simple, but for some reason it didn't appear in clear form to me.

from dryioc.

jzabroski avatar jzabroski commented on August 23, 2024

You're welcome, buddy! I should be thanking you for such a great library. I would trade 99% of the theory I know to be as good an engineer as you.

If you want to learn more about SSA Form, books by Andrew Appel on writing compilers in and for ML are a great resource. He also has a bunch of brilliantly lucid research papers on compiler system design that can be applied to all kinds of non-compiler systems. In particular, he has a technical note on how to bootstrap a compiler which to me is still the gold standard.

from dryioc.

dadhi avatar dadhi commented on August 23, 2024

There is also a performance problem to consider when creating a scoped dependencies in the scoped sevice, that can be directly mitigated by using fan-out ImMapArray.

When first created dependency will be added to scoped items ImMap, it effectively will cause to retry the holder sergice creation. Because upper service should be stored in the same items collection.

Having split / slots of items should help cause the dependency and holder can be stored independently.

from dryioc.

dadhi avatar dadhi commented on August 23, 2024

As a result, I ended up compiling nested lambdas once.
In interpreter, I could not evaluate expression once and use it results because
it conflicts with the Service reuse. In a sense I am already checking
if service is created for Scoped / Singleton reuse.

from dryioc.

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.