live model transformations driven by incremental pattern matching

Post on 07-Jul-2015

1.782 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

Conference presentation at ICMT 2008.

TRANSCRIPT

Live model transformations drivenLive model transformations driven by incremental pattern matchingy p g

István Ráth (rath@mit.bme.hu)Gábor BergmannAndrás ÖkrösDániel Varró

B d t U i it f T h l d E i ICMT J l 2 2008Budapest University of  Technology and Economics ICMT, July 2, 2008

OverviewOverview

I t d ti• Introduction

• Live transformations

• The VIATRA implementation

• Future work

• Summary

INTRODUCTION

Model transformations and incrementality

• K i f MT• Key usage scenarios for MT:– Mapping between languages or various levels of abstraction– Intra‐domain model manipulation

• Working with evolvingmodels– Constant changes & modifications– Largemodelsg

• Problem: (re)transformations are slow– To execute… (large models)– and to re‐execute again and again (batch execution)– and to re‐execute again and again (batch execution).

• Solution: incrementality– Take the source model, and its mapped counterpart;

U h i f i b h h d l h d– Use the information about how the source model was changed;– Map and apply the changes (but ONLY the changes) to the target 

model.

Towards incrementalityTowards incrementality

• How to achieve incrementality?– Incremental updates: avoid re‐generation.p g

• Don’t recreate what is already there.

• Use reference (correspondence) models.Use reference (correspondence) models.

Incremental updatesIncremental updates

modificationS2S1

modificationS3 Sn

t tR tR tR

T2T1merge

T3 Tn

Towards incrementalityTowards incrementality

• How to achieve incrementality?– Incremental updates: avoid re‐generation.p g

• Don’t recreate what is already there.

• Use reference (correspondence) models.Use reference (correspondence) models.

– Incremental execution: avoid re‐computation.• Don’t recalculate what was already computed• Don t recalculate what was already computed.

• How?

Live transformations0Live transformations0

S2S1

modification

S3 Sn

t tL tL tLtransformation context

T2T1

update

T3 Tn

0 Hearnden‐Lawley‐Raymond. Incremental Model Transformation for the Evolution of Model‐driven Systems.MODELS 2006.

Live transformations?Live transformations?

E ti ll diff t ti d• Essentially: a different execution mode.– More than “simple” incremental execution…

• Run as “daemons”• Run as  daemons– whenever model changes occur

• Maintain a transformation contextMaintain a transformation context– To persist (cache) the execution state

• Model changes can be instantly mapped– Input

• what has changed (creation, deletion)• where has the change occurred (source reference target)• where has the change occurred (source, reference, target)

– Output: • actions (what to do)

Possible applicationsPossible applications

/ i d i f i• M2M / inter‐domain transformations– Model synchronization on‐the‐fly

• M2M / intra‐domain transformations– Model animation/execution (based on dynamicModel animation/execution (based on dynamic semantics)

– Constraint checking on‐the‐fly (what‐if)Constraint checking on the fly (what if)

• M2CI t l d l d h i ti (DSML )– Incremental model‐code synchronization (DSMLs)

• ...

GRAPH TRIGGERS IN VIATRA2

Graph transformationsGraph transformations

h i i b d l• Graph rewriting based on rules• Driven by graph patternsy g p p

– Subgraph to be matched in the model graph– A set of constraints (type, attribute value,A set of constraints (type, attribute value, structural, …)

• ExecutionExecution– Declarative approaches (GT rules, TGG)I ti ( i d) h ( li it t l– Imperative (mixed) approaches (explicit control flow)

Incremental graph pattern matchingIncremental graph pattern matching

• Graph transformations require pattern matchingg

• Goal: retrieve the matching set quickly

H ?• How?– Store (cache) matchings execution context

– Update them as the model changes

– Update precisely incrementality– Update precisely  incrementality

Core idea: use RETE1 nets

INPUT• RETE networknode: (partial) matches of a t3 Model space– node: (partial) matches of a (sub)pattern

– edge: update propagation• Demonstrating the principle

k2k1t3

t3

t3t3 t3

p1p2p3 t2t1

d

Model space

• Demonstrating the principle– input: Petri net– pattern: fireable transition

: Place : Transition: Tokenk2k1p1 p2 t2t1 t3p3

Input nodes

p1

– Model change: new transition (t3)

t1 p2, k2p1, k1

t3

Intermediate 

p2p3t2

p2, k2, t3p1, k1, t1nodes

t2

p1, k1, t1, p3t3 p2, k2, t2, p3

p2, k2, t3

Production nodeProduction node1 Forgy, C.L.: RETE: A fast algorithm for the many pattern/many object pattern match problem. AI 1982.

UpdatesUpdates

N d d h h d l h• Needed when the model space changes• VIATRA notification mechanism (EMF is also possible)

– Transparent: user modification, model imports, results of a transformation, external modification, …  RETE is always updated!updated!

• Input nodes receive elementary modifications and release an update tokenp– Represents a change in the partial matching (+/‐)

• Nodes process updates and propagate them if neededp p p p g– PRECISE update mechanism

Event driven live transformationsEvent‐driven live transformations

A id t t d l l t 2• An idea: represent events as model elements.2

• Our take: represent events as changes in the matching set of a patternset of a pattern.– ~generalization

• Incrementality: persistent contexty p– matching sets cached in RETE networks  efficiency!– global cache (“session”)

• Formalism– Specify WHEN and HOW to (re)actSh ld b “MT lik ”– Should be “MT‐like”

2 E. Guerra – J. de Lara. Event‐Driven Grammars: Towards the Integration of Meta‐modelling and Graph Transformation, 2004

FormalismFormalism

@ i ( i i i “ i ” i i “ ” d “ l ”)@trigger(sensitivity=“rise”, priority=“1”, mode=“always”)gtrule mapClass() ={{precondition pattern pre(C) = { class(C); }postcondition pattern post(C,T) = {

Graph transformation rule marked as a live transformation 

unit (trigger)Annotations to specify execution d

High level support for:‐Model element creation/deletion

Table(T);mapping(M,C,T);

}Precondition pattern: defines the graph pattern whose

modes‐ Attribute value changes (special language constructs)

Arbitrarily complex changes}action { 

rename(T, name(C));  

the graph pattern whose matching set changes trigger 

the executionPostcondition pattern:

‐ Arbitrarily complex changes (involving multiple model elements)‐Model changes from any source rename(T, name(C));  

debug(“Table created: “ + fqn(T));}

Postcondition pattern: describes how the model is to 

be changed declarativelyAction sequence: imperative model modification, debug i i d i

g y(user editing, transformations, model 

imports, …)} printing, code generation, …

ExecutionExecution

Transaction1 Transaction2Commit

Matching set delta monitor

PAfall

trigger actions

PBrise

ExecutionEngine

Interesting questions:

Triggerq e e

‐ Serialization (priority ordering, conflicts, race 

queue

Incre‐mentalPM

conditions)‐ Parallel execution

PM

APPLICATIONS & FUTURE WORK

Case studiesCase studies

• Domain‐specific visual languages (ViatraDSM)– Incremental, on‐the‐fly constraint evaluation , y(&enforcement)

– On‐the‐fly abstract‐concrete synchronization‐‐ VIATRA2 is not limited to the „source target” scenarioOn the fly abstract concrete synchronization

• Metamodel‐driven, based on GMF specification models

Incremental code generation

‐‐ can be used to map a DSML into multiple concrete syntax 

representations (analysis models, – Incremental code generation• Model‐code synchronization

3

p ( yarchitectural models, etc) 

simultaneously, on multiple levels of abstraction– Model animation & simulation3abstraction

3 Ráth‐Vágó‐Varró. Design‐time simulation of domain‐specific models by incremental pattern matching. Accepted for VL/HCC 2008.

Performance4Performance4Object-Relational Mapping

100000

10000

]

b ild VIATRA/RETE

1000

cutio

n tim

e [m

s build – VIATRA/RETEsync – VIATRA/RETEbuild – VIATRA/LSsync – VIATRA/LS‐‐ Sub‐1000ms execution time for UML 

d l 5000 d100

Exe

c models < 5000 nodes‐‐ Low‐order‐polynomial characteristics (compared to exponential with local 

search)

1010 100 1000 10000 100000

Model size [node count]

search)‐‐ Acceptable execution time (n.10s) for 

really large models  (100000+)

4 Bergmann‐Horváth‐Ráth‐Varró. A benchmark evaluation of incremental pattern matching in graph transformation. To appear in Proc. ICGT2008.

Future workFuture work

I i f• Improving performance– Parallel (multi‐core) executionRETE optimizations– RETE optimizations

• Language improvementsMore compact notations– More compact notations

– Static type checking– Debugging support– Debugging support

• EMF support– Incremental pattern matching & matching set– Incremental pattern matching & matching set detection (EMFT)

– Java API based on the VIATRA language

ConclusionConclusion

i f i i f i l h• Live transformation engine for incremental graph transformations– Novel approach based on matching set changes, supported by the new, high performance incremental pattern matching enginepattern matching engine

• VIATRA2 R3htt // li / t– http://eclipse.org/gmt

– http://wiki.eclipse.org/VIATRA2A il bl i l ( i i A )– Available as a preview release (coming in August)

• Thank you.

top related