-
Notifications
You must be signed in to change notification settings - Fork 3
Adding possibility to observe nodes #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
f788ab2
to
8ccfdea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In delta protocol, we consciously decided to only have observers on partitions.
Main reason: If they're on nodes, each observer (or a shared superclass) has to keep track of all newly added / removed nodes, and keep attaching / removing itself from them. It also gets more tricky if we moved a node from on parent to the other, and have observers on both -- who gets the message?
Implementation-wise this very simple in C#: We walk up parents until we find the root (or first IPartitionInstance
, we have that there). If we find one, we check if there's an observer registered, and do the same thing as here.
Of course, this implementation can be used to satisfy delta spec. But I think we should only have two pretty different strategies for such a similar task if we have a good reason to do so.
core/src/main/java/io/lionweb/model/impl/AbstractClassifierInstance.java
Outdated
Show resolved
Hide resolved
Thank you, I did not think about such approach. Let me think about it and get back to you |
One thing I would not like about having an observer on the partition is this: I want to be sure that when we have no observers the performance issue is as small as it can be. Currently we have some checks to verify if the current |
Before doing any optimization on this I'd measure the actual impact. |
Normally I would postpone optimizations, but for years I have been fighting a lot of performance issues and at this time we are using LionWeb Java for projects where we cannot afford worsening performance. For this reason so I want to be careful and ensure we do not merge anything that would make performance significantly worse when observers are not used. If a performance hit is acceptable for those who needs to use observers, others should not experience any change. The problem with measuring the impact would be that it is easy to do "in the wild", using the library for a while on different use-cases, but it is for me difficult to reproduce it "in lab", for this reason I tend to err on the side of caution.
So that would mean having a field with the pointer to the observer, with the only difference that the public methods to register/unregister observers would work only for partitions, right?
That also would be reasonable |
Code Coverage
|
cf52bbf
to
3c980f1
Compare
Here we provide the code to observe nodes. This is a pre-requisite to implement Delta and the code has been extracted from the branch where delta is being implemented.
dirty
to make it knows that it should update the cache at the next access)Given this change was very impactful we started measuring coverage, and set the rule to get coverage to 60%+ for each file tested so we added a lot of tests and comments as needed.