|
Re: How to prevent traversal of objects (part 2) [message #1698547 is a reply to message #1698526] |
Tue, 16 June 2015 11:05 |
Zoltan Ujhelyi Messages: 392 Registered: July 2015 |
Senior Member |
|
|
Hi,
in general, the Base Indexer (that is indeed implemented with the NavigationHelper class) traverses the entire model, and indexes everything selected with the register* methods. The Queries.instance.prepare(engine) call evaluates all pattern definitions from the selected files, and calls all register* methods that the Rete engine needs for operation (basically, all/most EClass, EDataType and EReference elements mentioned in the description - the truth is a bit more complex, but among these lines), and traverses the model once for all queries.
There are two tasks that might take up the 18 seconds you have measured: (1) the traversal of the model itself (basically, we are following the containment hierarchy to visit every model element), and the (2) index/Rete network building. The latter case usually results in large memory consumption of the pattern matcher as well.
If you want to limit the traversal of the model you can add filters to your engine using a BaseIndexOptions instance: you can filter out resources or model elements as well. However, as the traversal follows the containment hierarchy, filtering out a single model element filters out all elements it has contained. For this reason, you could do something along the following:
BaseIndexOptions options = new BaseIndexOptions().withObjectFilterConfiguration(new IBaseIndexObjectFilter() { «add filter code here»});
EMFScope scope = new EMFScope(«resourceset», options);
IncQueryEngine engine = IncQueryEngine.on(scope);
If not the traversal, but the indexing/Rete building is slow, then you have to try to find out which pattern causes the issue, and refactor/remove the problematic parts. The QueryPerformanceTest abstract class helps to find out whether there is some pattern by measuring the JVM heap size and execution times (http://git.eclipse.org/c/incquery/org.eclipse.incquery.git/tree/tests/org.eclipse.incquery.testing.core/src/org/eclipse/incquery/testing/core/QueryPerformanceTest.xtend), but after that it needs some manual adjustments.
I hope this was helpful. If not, feel free to ask for clarification or any follow-up question that comes up.
Cheers,
Zoltán
[Updated on: Tue, 16 June 2015 11:06] by Moderator Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02994 seconds