Efficient model transformations by combining pattern matching strategies

29
Budapest University of Technology and Economics Fault-tolerant Systems Research Group Efficient Model Transformations by Combining Pattern Matching Strategies Gábor Bergmann, Ákos Horváth, István Ráth, Dániel Varró

description

Conference presentation at ICMT 2009.

Transcript of Efficient model transformations by combining pattern matching strategies

Page 1: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

Efficient Model Transformations by Combining Pattern Matching Strategies

Gábor Bergmann, Ákos Horváth, István Ráth, Dániel Varró

Page 2: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

Talk Overview

Introduction GT & PM overview

Hybrid PM Measurements

Page 3: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

Introduction

 Common problem to be solved by model transformation tools: − Efficient query and manipulation of complex graph-

based patterns  One possible solution: − Graph transformation

Page 4: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

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

Page 5: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

Talk overview

Introduction GT & PM overview

Hybtid PM Measurements

Page 6: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

Metamodeling

Instance model

Package Schema

Class Table

Association

Attribute

ForeignKey EndPoint

Column

schemaRef

tableRef

tableRef

fKeyRef

columnRef Metamodel

java: Package

lang: Package

jar: Package

jarEntry: Class

jarFile: Class

Page 7: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

schemaRule

Phases of GT matching – Pattern Matching phase – Updating phase: delete+ create

Graph Transformation

Pattern Matching is the most critical issue from the performance viewpoint (in our experience)

Con: Container

SN:Schema NEG

P: Package

:schemaRef

{NEW} <<contains>>

{NEW}

java: Package

lang: Package

jar: Package

Schema

:schemaRef

Page 8: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

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

Page 9: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

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

Page 10: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

Local Search based Pattern Matching Example

P

1

2

3

Search plan

Constraint checking (NAC, injectivity, etc.)

Search sequence

order of traversal in the search plan

Con

schemaRule

Con: Container

SN:Schema NEG

P: Package

:schemaRef

<<contains>>

<<contains>>

frequently used & efficient solution

Page 11: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

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

Page 12: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

INPUT •  RETE net

–  nodes: intermediate matchings –  edge: update propagation

•  Example –  input: schemaRule pattern –  pattern: contained Package –  update: new package

Package Class

c2 c1

p1 p2 c2 c1

<<contains>> p3, p4

NAC p2, s1

p4 p4

p4 p4

p1 p2 p3

p4

p1, p2

p3

p4

p3, p4

Incremental Pattern Matching Example

p3: Package

p1: Package

p2: Package

c1: Class s1:Schema p4: Package

p1, p3

schemaRef

Schema s1

p4

s1

out p1, p3 p3,p4

p4

Page 13: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

Talk overview

Introduction GT & PM overview

Hybrid PM Measurements

Page 14: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

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)

Page 15: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

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

Page 16: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

Case study: ORM Synchronization : Package

: Class

: Attribute : Attribute

: Schema

: Table

: Column : Column

:schemaRef

:columnRef

:tableRef

:columnRef

Transformation workflow

Check source model

Perform mapping

Modify source model

Synchronize

Page 17: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

Phases  Check Phase

− Well-formedness checking − Static graph structure − No model manipulation

  Initial Transformation − Match reusability − Unidirectional − Complex rules − Batch like execution

 Refactoring − Single rule executed:

move package in the hierarchy

− Manual execution

 Synchronization − Match reusability − Unidirectional − Simple rules − Live execution

Page 18: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

Phases  Check Phase

− Simple patterns, looking only for the first match

− INC: cache construction penalty high

− LS may be a better choice

  Initial Transformation − Processes the entire

model (full traversal) − Match set may not fit into

memory − Solution: decompose, use

LS for certain patterns

 Refactoring − Move in containment

hierarchy: very expensive cache update

− LS can be significantly better

 Synchronization − INC significantly better (as

demonstrated at ICGT08)

Page 19: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

Assign a PM implementation on a per-pattern (per-rule) basis ability to fine tune performance on a very fine

grained level.

Hybrid PM in the source code

Page 20: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

Talk overview

Introduction GT & PM overview

Hybrid PM Measurements

Page 21: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

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

Page 22: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

Composite ORM Synchronization benchmark

Hybridscalesbe-erwith

increasinglylargemodels!

Page 23: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

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)

Page 24: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

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

Page 25: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

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

Page 26: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

AntWorld Results

Linear characteristic retained, slower by

only a constant multiplier

Page 27: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

Memory footprint

Linear reduction in memory overhead

Page 28: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

Summary

 In short: you may get a linear decrease in memory for a linear increase in execution time retains complexity class characteristics

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

Page 29: Efficient model transformations by combining pattern matching strategies

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

?