BudapestUniversity of Technology andhome.mit.bme.hu/~rath/ppt/GRaMoT08-Rath.pdfp1p2p3 k1k2 t1 t2 t3...

26
Incremental pattern matching in the VIATRA d lt f ti t VIATRA modeltransf ormation sys t em Gábor Bergmann András Ökrös István Ráth ([email protected]) Dániel Varró Department of Measurement and Dániel Varró Gergely Varró Department of Measurement and Information Systems Budapest University of Technology and Budapest University of Technology and Economics

Transcript of BudapestUniversity of Technology andhome.mit.bme.hu/~rath/ppt/GRaMoT08-Rath.pdfp1p2p3 k1k2 t1 t2 t3...

  • Incremental pattern matching in the VIATRA d l t f ti tVIATRA model transformation systemGábor BergmannAndrás ÖkrösIstván Ráth ([email protected])Dániel Varró Department of Measurement andDániel VarróGergely Varró

    Department of Measurement and Information SystemsBudapest University of Technology andBudapest University of Technology and Economics

  • OverviewOverview

    • IntroductionIntroduction

    • Concepts• Concepts

    P f l i• Performance analysis

    • Future work

    • Summary

  • IntroductionIntroduction

  • Incremental model transformationsIncremental model transformations• Key usage scenarios for MT:

    ▫ Mapping between languages▫ Intra‐domain model manipulation

    Model executionValidity checking (constraint evaluation)Validity checking (constraint evaluation)

    • They work with evolvingmodels.▫ Users are constantly changing/modifying them.▫ Users usually work with largemodels.Users usually work with largemodels.

    • Problem: transformations are slow▫ To execute… (large models)▫ and to re‐execute again and again (always starting from scratch).

    • Solution: incrementality▫ Take the source model, and its mapped counterpart;▫ Use the information about how the source model was changed;

    M d l h h (b ONLY h h ) h d l▫ Map and apply the changes (but ONLY the changes) to the target model.

  • Towards incrementalityTowards incrementality

    • How to achieve incrementality?How to achieve incrementality?▫ Incremental updates: avoid re‐generation.

    Don’t recreate what is already thereDon t recreate what is already there.Use reference (correspondence) models.

    ▫ Incremental execution: avoid re‐computation.Incremental execution: avoid re computation.Don’t recalculate what was already computed.How?

  • Incremental graph pattern matchingIncremental graph pattern matching• Graph transformations require pattern matchingp q p g• Goal: retrieve the matching set quickly• How?▫ Store (cache) matchings▫ Update them as the model changes

    U d t i l (i t lit )Update precisely (incrementality)• Expected results: good, if…▫ There is enough memory (*)There is enough memory ( )▫ Queries are dominant▫ Model changes are relatively sparse (**)▫ e.g. synchronization, constraint evaluation, …

  • Operational overviewOperational overview

    XForm interpreter model manipulationpattern 

    matching

    Incremental

    matching

    VIATRA Model space

    Incrementalpatternmatcher

    event notification

    updates

  • Architecture

    LS tt

    Architecture

    XML XForm

    LS patternmatcher

    V

    Modelparser

    XFormparser

    serializer

    Native importer &l d i t f

    interpreter

    VIATRA

    Incrementalpatternmatcherloader interface

    A2 Fra

    matcher

    Core interfaces

    mew

    o

    VIATRA Model space

    ork Program model store

  • ConceptsConcepts

  • Core idea: use RETE nets

    INPUT• RETE network▫ node: (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▫ Model change: new transition 

    (t3)

    t1p2, k2p1, k1

    t3

    Intermediate p1

    3

    t1

    p2, k2, t3p1, k1, t1nodes

    p2p3t2

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

    p2, k2, t3

    Production nodet3

    Production node

  • RETE network constructionRETE network construction• Key: pattern decompositiony p p▫ Pattern = set of constraints (defined over pattern variables)▫ Types of constraints: type, topology (source/target), h h ( ) b lhierarchy (containment), attribute value, generics (instanceOf/supertypeOf), injectivity, [negative] pattern calls, …calls, …

    • Construction algorithm (roughly)▫ 1. Decompose the pattern into elementary constraints (*)▫ 2. Process the elementary constraints and connect them with appropriate intermediate nodes (JOIN, MINUS‐JOIN, UNION )UNION, …)

    ▫ 3. Create terminator production node

  • Key RETE componentsKey RETE components

    • JOIN node INPUTINPUTINPUT

    JOIN node▫ ~relational algebra: natural joinnatural join

    JOIN

    • MINUS‐JOINNegative existence JOIN▫ Negative existence JOIN

    PRODUCTIONsourcePlace

  • Other VIATRA featuresOther VIATRA features• Pattern calls▫ Simply connect the production nodes▫ Pattern recursion is fully supported• OR patterns• OR‐patterns▫ UNION intermediate nodes• Check conditions▫ check (value(X) % 5 == 3)▫ check (length(name(X)) 

  • UpdatesUpdates

    • Needed when the model space changesNeeded when the model space changes• VIATRA notification mechanism (EMF is also possible)▫ Transparent: user modification, model imports, results of aTransparent: user modification, model imports, results of a transformation, external modification, …  RETE is always updated!

    • Input nodes receive elementary modifications and release an update token▫ Represents a change in the partial matching (+/‐)• Nodes process updates and propagate them if needed▫ PRECISE update mechanism

  • Performance analysisPerformance analysis

  • PerformancePerformance• In theory…▫ Building phase is slow (“warm‐up”)

    How slow?▫ Once the network is built, pattern matching is an , p g“instantaneous” operation.

    Excluding the linear cost of reading the result set.▫ But… there is a performance penalty on model manipulation.p p y p

    How much?• Dependencies?▫ Pattern sizePattern size▫ Matching set size▫ Model size▫ ?▫ …?

  • BenchmarkingBenchmarking• Example transformation: Petri net simulation▫ One complex pattern for the enabledness condition▫ Two graph transformation rules for firing▫ As‐long‐as‐possible (ALAP) style execution (“fire at will”)▫ Model graphs:

    A “large” Petri net actually used in a research project (~60 places, ~70 transitions, ~300 arcs)S li t ti ti i li ( t 100000Scaling up: automatic generation preserving liveness (up to 100000 places, 100000 transitions, 500000 arcs)

    • Analysis▫ Measure execution time (average multiple runs)▫ Measure execution time (average multiple runs)▫ Take “warm‐up” runs into consideration

    • Profiling▫ Measure overhead network construction time▫ Measure overhead, network construction time▫ “Normalize” results

  • Profiling resultsProfiling results• Model manipulation overhead: ~15% (of overall CPU p (time)▫ Depends largely on the transformation!• Memory overhead• Memory overhead▫ Petri nets (with RETE networks) up to ~100000 fit into 1‐1.5GB RAM (VIATRA model space limitations)

    ( )▫ Grows linearly with model size (as expected)▫ Nature of growth is pattern‐dependent• Network construction overheadNetwork construction overhead▫ Similar to memory; pattern‐dependent.▫ PN: In the same order as VIATRA’s LS heuristics initializationinitialization.

  • Execution timesExecution timesSparse Petri net benchmark

    Matches/outperforms GrGEN.NET for large 

    d l d hi h1000000

    Viatra/RETE ( 1k)

    Three orders of 

    models and high iteration counts.

    10000

    100000

    ms)

    (x1k)Viatra/LS (x1k)

    G G NET ( 1k)

    magnitude and growing…

    1000

    on time (m GrGenNET (x1k)

    Viatra/RETE ( 1M)

    10

    100

    Executio (x1M)

    GrGen.NET (x1M)

    100 1000 10000 100000Petri net size

  • Benchmarking summaryBenchmarking summary

    • Predictable near‐linear growthPredictable near linear growth▫ As long as there is enough memory▫ Certain problem classes: constant execution time☺▫ Certain problem classes: constant execution time ☺▫ A ga

  • Improving performanceImproving performance

    • StrategiesStrategies▫ Improve the construction algorithm

    Memory efficiency (node sharing)Memory efficiency (node sharing)Heuristics‐driven constraint enumeration (based on pattern [and model space] content)p [ p ] )

    ▫ ParallelismUpdate the RETE network in parallel with the transformationParallel network construction

    ▫ ?

  • Future workFuture work

  • More benchmarkingMore benchmarking…

    • Ongoing researchOngoing research▫ Extending the Varro benchmark

    Mutex STS/LTSMutex STS/LTSORM

    ▫ Extended benchmarking use casesExtended benchmarking use casesSimulation (model execution)SynchronizationyConstraint evaluation

    ▫ Parallel transformations

  • Event‐driven live transformationsEvent‐driven live transformations• Problem: MT is mostly batch‐likey▫ But models are constantly evolving  Frequent re‐transformations are needed formappingmappingsynchronizationconstraint checking…

    • An incremental PM can solve the performance problem, but a formalism is needed▫ to specify when to (re)act▫ and how.• Ideally the formalism should be MT‐like• Ideally, the formalism should be MT like.

  • Event‐driven live transformations (cont’d)Event‐driven live transformations (cont d)

    • An idea: represent events as model elements.p• Our take: represent events as changes in the matching set of a pattern.▫ ~generalization• Live transformations

    i t i th t t ( i bl l l b l i bl )▫ maintain the context (variable values, global variables, …);▫ run as a “daemon”, react whenever necessary;▫ as the models change the system can react instantly sinceas the models change, the system can react instantly, since everything needed is there in the RETE network: no re‐computation is necessary.

    • Paper accepted at ICMT2008.

  • SummarySummary

    • Incremental pattern matching support integratedIncremental pattern matching support integrated into VIATRA2 R3▫ Based on the RETE algorithmBased on the RETE algorithm▫ Provides full support for the pattern language▫ High performance in certain problem classes▫ High performance in certain problem classes• Future▫ Performance will be further improved▫ Performance will be further improved▫ New applications in live transformations