Axa Assurance Maroc - Insurer Innovation Award 2024
Efficient model transformations by combining pattern matching strategies
1. Budapest University of Technology and Economics
Efficient Model Transformations
by Combining Pattern Matching Strategies
Gábor Bergmann, Ákos Horváth,
István Ráth, Dániel Varró
Fault-tolerant Systems Research Group
2. Budapest University of Technology and Economics
Talk Overview
GT & PM
Introduction overview
Hybrid PM Measurements
Fault-tolerant Systems Research Group
3. Budapest University of Technology and Economics
Introduction
Common problem to be solved by model
transformation tools:
− Efficient query and manipulation of complex graph-
based patterns
One possible solution:
− Graph transformation
Fault-tolerant Systems Research Group
4. Budapest University of Technology and Economics
Benchmarking
Aim:
− systematic and reproducible measurements
− on performance
− under varying and precisely defined circumstances
Overall goal:
− help transformation engineers in selecting tools
− serve as reference for future research
Popular approach in different fields
− AI
− relational databases
− rule-based expert systems
Fault-tolerant Systems Research Group
5. Budapest University of Technology and Economics
Talk overview
GT & PM
Introduction overview
Hybtid PM Measurements
Fault-tolerant Systems Research Group
6. Budapest University of Technology and Economics
Metamodeling Package
schemaRef
Schema
Class tableRef
Table
Association tableRef
fKeyRef
EndPoint ForeignKey
columnRef
Metamodel Attribute Column
Instance model
jarEntry: Class lang: Package
jarFile: Class jar: Package java: Package
Fault-tolerant Systems Research Group
7. Budapest University of Technology and Economics
Graph Transformation
schemaRule :schemaRef
Con: Container java: Package Schema
<<contains>> NEG {NEW}
P: Package SN:Schema
lang: Package
:schemaRef {NEW}
jar: Package
Phases of GT matching
– Pattern Matching phase
– Updating phase: delete+ create
Pattern Matching is the most critical issue from the
performance viewpoint (in our experience)
Fault-tolerant Systems Research Group
8. Budapest University of Technology and Economics
Pattern matching techniques
Execution strategies
− Interpreted: AGG (Tiger), VIATRA, MOLA, Groove, ATL
● underlying PM engine
− Compiled: Fujaba, GReAT, PROGRES, Tiger, VMTS,
GrGEN.NET, ...
● directly executed as C(#) or Java code
Algorithms
− Constraint satisfaction: AGG (Tiger)
● variables + constraints
− Local search (LS): Fujaba, GReAT, PROGRES, VIATRA,
MOLA, Groove, Tiger (Compiled), GrGEN.NET, ...
● step-by-step extension of the matching
− Incremental (INC): VIATRA, Tefkat
● Updated cache mechanism
Fault-tolerant Systems Research Group
9. Budapest University of Technology and Economics
Traditional Local Search-based pattern
matching
Method
− usually defined at design/compile time
− simple search plan
− hard wired precedence for
constraint checking
(NAC, injectivity, attribute, etc.)
● Can be done adaptively
Good performance expected when:
− Small patterns, bound input parameters
Fault-tolerant Systems Research Group
10. Budapest University of Technology and Economics
Local Search based Pattern Matching Example
frequently used &
efficient solution
schemaRule
Con: Container Search plan
<<contains>> NEG Con
P: Package SN:Schema 1
:schemaRef <<contains>> 2
P
3
Constraint
checking (NAC, Search sequence
injectivity, etc.)
order of traversal
in the search plan
Fault-tolerant Systems Research Group
11. Budapest University of Technology and Economics
Incremental Pattern Matching
Goal
− Store matching sets
− Incremental update
− Fast response
Good performance expected when:
− frequent pattern matching
− Small updates
Possible application domain
− E.g. synchronization, constraints, model simulation,
etc.
In VIATRA: an adapted RETE algorithm
Fault-tolerant Systems Research Group
12. Budapest University of Technology and Economics
Incremental Pattern Matching Example
• RETE net
– nodes: intermediate matchings INPUT
p4
– edge: update propagation p1 p2 p3 c1 c2 s1 p4
• Example p4
p4 p4
– input: schemaRule pattern Package
Class Schema
– pattern: contained Package p1 p2 p3 p4
c1 c2 s1
– update: new package
p4
p1: Package
<<contains>>
p1, p2 p1, p3 p3, p4
p2: Package p3: Package p4
p3, p4
NAC
schemaRef p2, s1
s1:Schema c1: Class p4: Package
out
p1, p3 p3,p4
Fault-tolerant Systems Research Group
13. Budapest University of Technology and Economics
Talk overview
GT & PM
Introduction overview
Hybrid PM Measurements
Fault-tolerant Systems Research Group
14. Budapest University of Technology and Economics
Hybrid pattern matching
Idea: combine local search-based and
incremental pattern matching
Motivation
− Incremental PM is better for most cases, but…
● Has memory overhead!
● Has update overhead
− LS might be better in certain cases
Based on experience with a ”real world”
transformation application1
1Kovacs,
M., Lollini, P., Majzik, I., Bondavalli, A.: An Integrated Framework for the
Dependability Evaluation of Distributed Mobile Applications (SERENE’08)
Fault-tolerant Systems Research Group
15. Budapest University of Technology and Economics
Where LS might be better…
Memory consumption
− RETE sizes grow roughly linearly with the model
space
− Constrained memory trashing
Cache construction time penalty
− RETE networks take time to construct
− „navigation patterns” can be matched quicker by LS
Expensive updates
− Certain patterns’ matching set is HUGE
− Depends largely on the transformation
Fault-tolerant Systems Research Group
16. Budapest University of Technology and Economics
Case study: ORM Synchronization
:schemaRef
: Package : Schema
:tableRef
: Class : Table
:columnRef
: Attribute : Attribute : Column : Column
:columnRef
Transformation workflow
Check Modify
Perform
source source Synchronize
mapping
model
model
Fault-tolerant Systems Research Group
17. Budapest University of Technology and Economics
Phases
Check Phase Initial Transformation
− Well-formedness checking − Match reusability
− Static graph structure − Unidirectional
− No model manipulation − Complex rules
− Batch like execution
Refactoring Synchronization
− Single rule executed: − Match reusability
move package in the − Unidirectional
hierarchy − Simple rules
− Manual execution − Live execution
Fault-tolerant Systems Research Group
18. Budapest University of Technology and Economics
Phases
Check Phase Initial Transformation
− Simple patterns, looking − Processes the entire
only for the first match model (full traversal)
− INC: cache construction − Match set may not fit into
penalty high memory
− LS may be a better choice − Solution: decompose, use
LS for certain patterns
Refactoring Synchronization
− Move in containment − INC significantly better (as
hierarchy: very expensive demonstrated at ICGT08)
cache update
− LS can be significantly
better
Fault-tolerant Systems Research Group
19. Budapest University of Technology and Economics
Hybrid PM in the source code
Assign a PM implementation
on a per-pattern (per-rule)
basis ability to fine tune
performance on a very fine
grained level.
Fault-tolerant Systems Research Group
20. Budapest University of Technology and Economics
Talk overview
GT & PM
Introduction overview
Hybrid PM Measurements
Fault-tolerant Systems Research Group
21. Budapest University of Technology and Economics
Environment
Hardware and OS
− 1.8 GHz Intel Core2 Duo
− 2048 MB RAM
− Windows XP SP3
− Sun JVM 1.6.0_02 for VIATRA
Tool related
− VIATRA2 R3 Build 2009.02.03
− Standard services of the default distribution
Fault-tolerant Systems Research Group
22. Budapest University of Technology and Economics
Composite ORM Synchronization benchmark
Hybrid scales
be-er with
increasingly large
models!
Fault-tolerant Systems Research Group
23. Budapest University of Technology and Economics
Considerations for selecting PM strategy
Graph pattern static attributes
− Number of patterns
− Pattern size
− Containment constraints
Control structures
− Parameter passing
− Usage frequencies
− Model update cost
Model-dependent pattern characteristics
− Model statistics (instance count)
Fault-tolerant Systems Research Group
24. Budapest University of Technology and Economics
Adaptive hybrid pattern matching
Goal: provide (semi-) automatic aid for strategy
selection
Idea: monitor memory usage
− JVM telemetry
Prevent heap exhaustion
− Destroy match set cache structures
− Switch to LS
PM Strategy Used heap [MB] Transform phase
execution time [s]
LS 201 77.1
INC 353 13.6
Static hybrid 220 10.9
Adaptive hybrid 235 35.7
Fault-tolerant Systems Research Group
25. Budapest University of Technology and Economics
Further benchmarking
Paper for a GRaBaTS 2008 special issue in
STTT’09: Experimental assessment of
combining pattern matching strategies with
VIATRA2
In-detail investigation
− hybrid approach
− Transformation language-level optimizations
Optimization
− Based on experience with ICMT’09 paper
Fault-tolerant Systems Research Group
26. Budapest University of Technology and Economics
AntWorld Results
Linear characteristic
retained, slower by
only a constant
multiplier
Fault-tolerant Systems Research Group
27. Budapest University of Technology and Economics
Memory footprint
Linear reduction in
memory overhead
Fault-tolerant Systems Research Group
28. Budapest University of Technology and Economics
Summary
Optimization strategy Performance Memory footprint
LS High order polynomial Constant
Switch to INC Polynomial order reduction Linear increase with model
size
Switch to Hybrid Linear (~50%) reduction Linear (~50%) reduction
In short: you may get a linear decrease in
memory for a linear increase in execution time
retains complexity class characteristics
Fault-tolerant Systems Research Group