Comments (11)
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
glabalglobal 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.
This issue may help with #27
from dryioc.
Did some related work in #1
from dryioc.
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.
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.
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.
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.
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.
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.
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.
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)
- Consistent behavior of a faulty singleton HOT 2
- FactoryType is not forwarded in the RegisterMapping<TService, TRegisteredService> method HOT 1
- IDisposable dependencies does not get disposed when web request ends HOT 5
- Add the HotUsedInstance for fast access to skip all the resolution steps
- Conditional registrations
- MS DI AddKeyed... variant registration fails HOT 8
- Check for mismatch lifestyle scope between service and dependencies HOT 7
- troubleshooting sudden ArgumentException at TryInterpretSingletonAndUnwrapContainerException HOT 3
- [question/feature request] keyed services in delegate resolution HOT 8
- Use default constructor if no registration is found
- Add the global test option to run all tests with WithoutUseInterpretation option
- Feature Request: add global .WithDefaultServiceTypeCondition(Func<Type, bool> condition) method HOT 1
- System.NullReferenceException: Object reference not set to an instance of an object HOT 5
- 'WithConcreteTypeDynamicRegistrations' results in unintended instantiation HOT 3
- Exception: Window already exists HOT 4
- Resolve enforces passed arguments to be used (and fails because of it) HOT 4
- Type registered with Singleton instantiating multiple times
- [BUG] Resolve<> crashes with the misleading, casting-related Exception when class is also registered using RegisterInitializer HOT 5
- Virus Warning with DryIoc Version 5.4.3 on Some Antivirus Software HOT 1
- Resolving func-wrapper when having circular-dependency throws RecursiveDependencyDetected HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dryioc.