|
Re: Disadvantages of IMatchUpdateListener [message #1830475 is a reply to message #1830468] |
Mon, 27 July 2020 13:35 |
Gabor Bergmann Messages: 36 Registered: July 2009 |
Member |
|
|
Hi Nadine,
Nadine Rösl wrote on Mon, 27 July 2020 14:45The documentation mentions, that this approach is risky to use:
Be very careful when using match update listeners, as sometimes they are called while the model indexes are in an inconsistent state. For this reason, do not update the underlying model and do not execute further model queries. (Tutorial Section 3.2.4.1)
What does this mean exactly? In which cases does such an inconsistent state occur?
IMatchUpdateListener is invoked in the midst of EMF delivering its change notifications and Viatra Query updating its stored query results. If you request query results at this point (in the body of either of the interface methods), you may get unpredictable results.
Nadine Rösl wrote on Mon, 27 July 2020 14:45
Are there any further downsides or problems using IMatchUpdateListener, if the model is not queried or modified when the listener is notified?
I can only think of one: transients.
Quick example: imagine an EMF database of people with residence addresses and marriages. Assume a VQL pattern "cohabitingMarriedCouple" that looks for marriages where both spouses cohabit at the same address of residence. If a couple moves from town A to town B and you correspondingly update the residence fields of the two EMF objects representing the two persons, there will be a short transient where one spouse is already updated to the new address but the other one is not. IMatchUpdateListener will let you observe the disappearance of this match of "cohabitingMarriedCouple", and then its re-appearance - even though this is just a short-term transient.
If you modify your output model in a way that the final state of that model depends only on the final query result sets, independently of the exact sequence of transient notifications received, then you should be OK.
Nadine Rösl wrote on Mon, 27 July 2020 14:45
But using our EMF model the memory consumption is too high for our requirements
Just out of curiosity: How large are your models? How many matches do you have of your main patterns (especially those you use as direct preconditions to the rules updating the target model)? What are our memory limits?
It is really surprising that a given set of patterns fit into your memory limits with incremental pattern matching, but the supposedly small overhead of the EVM pushes it through the limit.
Cheers,
Gábor
|
|
|
|
|
Re: Disadvantages of IMatchUpdateListener [message #1830521 is a reply to message #1830519] |
Tue, 28 July 2020 12:12 |
Nadine Rösl Messages: 3 Registered: July 2020 |
Junior Member |
|
|
Hi,
I forgot to mention it: the garbage collector was explicitly called after the initialization of the engines and after disposing. Without that, the diagram for the EVM looks worse (then you wouldn't see the segment where it stays at 3-400MB).
So perhaps the memory consumption is pretty equal, when the engine is initialized and only some small changes are made. But before that or when working with the model extensively the differences are visible. I attached another example (like before: left: without Viatra, middle: with Listeners, right: with EVM).
The scenario for this example was:
- Load Model
- Initialize Engine (if used)
- Garbage Collector
- Delete 10 000 entities (which are part of multiple matches of different queries)
- Dispose engine
- Garbage Collector
This is perhaps not the most common use case, but we wanted to know, how Viatra would react in such cases. Even if these are just temporarly peaks in memory consumption, it's interessting to see those differences.
Cheers,
Nadine
|
|
|
Powered by
FUDForum. Page generated in 0.02171 seconds