Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [henshin-dev] Improving Variable Sorting

Hi Matthias, 
this is a nice performance tweak for the match finder. Thanks a lot for your contribution! I will add your patch to the development branch.

Cheers, 
Christian


Von Samsung Mobile gesendet



-------- Ursprüngliche Nachricht --------
Von: Matthias Tichy <tichy@xxxxxxxxxxx>
Datum:
An: henshin-dev@xxxxxxxxxxx
Betreff: [henshin-dev] Improving Variable Sorting


Dear all,

I battled with a weird performance problem in the Henshin interpreter
quite some time. My henshin rule contains two nodes in the lhs. One node
(T) is fixed to an object by a rule parameter so it is already contained
in the partial match. The other (I) has an attribute which is constrained
using a parameter. Both are connected by a reference. In my example, there
are 2000 objects which are valid with the type constraint for I but only
200 of them are valid when taking the reference constraint for the fixed T
into account.

While debugging the VariableComparator, i was surprised that node T has
been sorted in after node I which is not good as then the restriction of
the target domain in ReferenceConstraint does not work.

The reason for that is that the VariableComparator does not distinguish
between the two cases (attribute condition for I and fixed object for T)
in the original method isNodeMatched(). I divided this method into two.
One isNodeObjectMatched() considers only whether the node is already in
the partialMatch, the other isNodeAttributeMatched() only considers the
attribute condition. In the compare()-Method, i check now
isNodeObjectMatched() before isNodeAttributeMatched() which results in the
correct variable sorting. The performance increased for my example by a
factor of 10 due to the possible matchings for I is 200 instead of 2000
due the successful target domain restriction in ReferenceConstraint. All
tests still run successfully. This change should not decrease the
performance for any other case. (I believe :-) )

I attached the patch.

Cheers,

mtt

--
Matthias Tichy, Assistant Professor
Software Engineering Division
Department of Computer Science and Engineering
Chalmers University of Technology and University of Gothenburg, Sweden
Phone: +46-(0)31-772 6031
Email: matthias.tichy@xxxxxxxxx






Index: src/org/eclipse/emf/henshin/interpreter/impl/EngineImpl.java
===================================================================
--- src/org/eclipse/emf/henshin/interpreter/impl/EngineImpl.java (revision
1801)
+++ src/org/eclipse/emf/henshin/interpreter/impl/EngineImpl.java (working
copy)
@@ -461,8 +461,10 @@

// One of the nodes already matched or an attribute given as a
parameter?
if (partialMatch!=null) {
- if (isNodeMatched(n1)) return -1;
- if (isNodeMatched(n2)) return 1;
+ if (isNodeObjectMatched(n1)) return -1;
+ if (isNodeObjectMatched(n2)) return 1;
+ if (isNodeAttributeMatched(n1)) return -1;
+ if (isNodeAttributeMatched(n2)) return 1;
}

// Get the domain sizes (smaller number wins):
@@ -479,10 +481,14 @@

}

- private boolean isNodeMatched(Node node) {
+ private boolean isNodeObjectMatched(Node node) {
if (partialMatch.getNodeTarget(node)!=null) {
return true;
}
+ return false;
+ }
+
+ private boolean isNodeAttributeMatched(Node node) {
for (Attribute attribute : node.getAttributes()) {
String value = attribute.getValue();
if (value!=null) {


_______________________________________________
henshin-dev mailing list
henshin-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/henshin-dev

Back to the top