Query-driven incremental synchronization of view models

Views are key concepts of domain-specific modeling in order to provide specific focus of the designers by abstracting from unnecessary details of the underlying abstract model. Usually, these views are represented as models themselves (view models), computed from the source model. However, the efficient maintenance of views when the source model changes is challenging, as recalculation from scratch has to be avoided to achieve scalability. This benchmark aims to measure query-based view model creation performance from detailed source models with the EMF-IncQuery framework.

Authors:  Debreceni Csaba, Ákos Horváth, Ábel Hegedüs, Zoltán Ujhelyi, István Ráth and Dániel Varró

Case Study Overview

The benchmark uses a domain-specific model of a railway system that contains most typical class diagram constructs in the source metamodel. This metamodel will be instantiated and then abstracted to view model as an instance of view metamodel.

Source metamodel

Source Metamodel

A train route can be defined by a set of sensors between two neighboring signals. The state of a signal can be stop (when it is red), go (when it is green) or failure. Sensors are associated with track elements, which can be a track segment or a switch. The status of a switch can be left, right, straight or failure. A route can have associated switch positions, which describe the required state of a switch belonging to the route. Different route definitions can specify different states for a specific switch.

View metamodel

View Metamodel

View models consist of only connected virtual switches which abstract the instances of source metamodel. A VirtualSwitch represents a simple Switch from the source metamodel that is not in Failure state. Two VirtualSwitch elements are connected if the corresponding Switch elements are connected in the source model. The CountConnectedInFailure attribute shows the count of Switches that are connected to this VirtualSwitch and are in Failure state.

Derivation Rules

 

Name virtualSwitches
Annotations
@QueryBasedObject(eClass = "VirtualSwitch")
Pattern
pattern virtualSwitches(switchElement : Switch)
{
	neg find switchesInFailure(switchElement);
}
Textual description Finds the Switch elements from the source models and creates VirtualSwitch objects in the view model.
Name connectedTo
Annotations
@TraceLookup(source = trg, target = t)
@TraceLookup(source = src, target = s)
@QueryBasedFeature(source = s, target = t, feature = "connectedTo")
Pattern
pattern connectedTo(src : Switch, trg : Switch)
{
	find connectedSwitches(s,t);
	neg find switchesInFailure(s);
	neg find switchesInFailure(t);
}
Textual description Finds the connected Switch pairs from the source models, where none of them are in Failure state, then traces the corresponding VirtualSwitch elements and sets connectedTo reference.
Name  
Annotations
@TraceLookup(source = src, target = s)
@QueryBasedFeature(source = s, target = c, feature = "CountConnectedInFailure")
Pattern
pattern countConnectedInFailure(src : Switch, c)
{
	c == count find connectedSwitchesInFailure(src, _);
}
Textual description Counts the connected switches in failure state then traces the corresponding VirtualSwitch and sets CountConnectedInFailure attribute.

Helper patterns

 

Name switchesInFailure
Pattern
pattern switchesInFailure(switchElement : Switch)
{
	Switch.Switch_actualState(switchElement, ::PointStateKind_FAILURE);
}
Textual description Finds the Switch elements that are in Failure state.
Name connectedSegments
Pattern
pattern connectedSegments(source : Segment, target : Segment)
{
	Trackelement.TrackElement_connectsTo(source, target);
}
Textual description Finds the connected Segment pairs.
Name connectedSwitches
Pattern
pattern connectedSwitches(source : Switch, target : Switch) {
	Trackelement.TrackElement_connectsTo(source, target);	
} or {
	Trackelement.TrackElement_connectsTo(source, srcSegment);
	find connectedSegments+(srcSegment, trgSegment);
	Trackelement.TrackElement_connectsTo(trgSegment, target);	
}
Textual description Finds the connected Switches. These Switches can be connected directly or indirectly through some Segment elements.
Name connectedSwitchesInFailure
Pattern
pattern connectedSwitchesInFailure(source : Switch, target : Switch) {
	find connectedSwitches(source, target);
	neg find switchesInFailure(source);
	find switchesInFailure(target);
}
Textual description Finds Switch pairs that are connected where the target is in Failure state but the source is not in Failure state.

Measurement

All measurements were executed on a developer PC with a 3.5 GHz Core i7 processor, 16 GB RAM, Windows 7 and Java 7. To avoid interference between different executions, each time a new JVM was created with a 2 GB heap limit. The time to start up and shut down the JVM was not included in the measurement results.

Runtime Performance

 

Legend

Total time (ns): Model Load time + Transformation time + Pattern Load time + Rete Load time
Pattern Load time (ns): the required time to initialize the derivation rules
Transformation time (ns): the required time to execute the derivation rules and build up the view model
Model Load time (ns): the required time to load source model and metamodels
Rete Load time (ns): the required time to initialize the EMF-IncQuery enginge
Size: count of the objects in the source model

 

 

Example Total time (ns) Pattern Load time (ns) Transformation time (ns) Model Load time (ns) Rete Load time (ns) Size
Train 1, 2671394975, 509656729 355321177, 1087638955, 1228408588, 6032
  2367238358, 453831246 296549726, 978870655, 1091796681, 6032
  2387372976, 435701834 317077567, 938900421, 1131372817, 6032
  2356045490, 453368886 304705905, 963283194, 1088033054, 6032
  2368727823, 445738367 305975131, 958117907, 1104610866, 6032
  2362009185, 447577008 294226558, 962009885, 1105751156, 6032
  2395180562, 452372118 308036345, 961733053, 1125389286, 6032
  2322076290, 450173508 299207194, 958891226, 1063952200, 6032
  2384421173, 455479400 297189736, 971408160, 1115800816, 6032
  2399245524, 443077399 314282122, 950041656, 1134898117, 6032
Train 2, 3085963964, 444044415 465501056, 1155801388, 1464633223, 11710
  3127502715, 439503383 569822256, 1128403512, 1429253319, 11710
  3047750983, 441944694 523073000, 1138594068, 1386058244, 11710
  3222525113, 436875962 467127042, 1109680182, 1645690469, 11710
  3097677823, 448164802 473030353, 1131231338, 1493391920, 11710
  3036617333, 443541509 526420943, 1127680367, 1382491520, 11710
  3040201851, 440058505 476345040, 1132668003, 1431161678, 11710
  3154151191, 461241816 563608275, 1143739812, 1446767225, 11710
  3351079731, 443876390 524427988, 1157983662, 1668643578, 11710
  3125248390, 444425970 554495000, 1139229994, 1431496560, 11710
Train 4, 4050028354, 442377298 1085805274, 1228868905, 1735323838, 23180
  4046885484, 442084423 1009706027, 1208577931, 1828572354, 23180
  4402571589, 442311955 1105739780, 1287112654, 2009689984, 23180
  4261890634, 444326497 1055015992, 1221566266, 1985277456, 23180
  4214780244, 452378827 1012238060, 1213052453, 1989456476, 23180
  4285286848, 442803777 1060728525, 1203556748, 2020973280, 23180
  4044949704, 441373820 1058578631, 1203219532, 1783122370, 23180
  4123525849, 444612955 1077906675, 1235372262, 1810217452, 23180
  4027886197, 439615108 1028202117, 1216622094, 1783028439, 23180
  4260971168, 440365383 1060030758, 1199576089, 2001334276, 23180
Train 8, 6564483109, 495478805 2678911436, 1446046703, 2439485006, 46728
  6891715353, 501968743 2755135534, 1442999221, 2693550552, 46728
  6562924218, 493986131 2694280115, 1443131366, 2425473939, 46728
  6515051592, 438112224 2622168820, 1465205264, 2427629959, 46728
  6602688213, 435748216 2724581368, 1459845406, 2418225559, 46728
  6582888186, 483571251 2698598864, 1437905110, 2446342788, 46728
  6487792277, 491303868 2632431428, 1440782527, 2414536317, 46728
  6935608778, 519232070 2891919549, 1507922520, 2535727329, 46728
  7115764353, 475664483 2887509786, 1557997256, 2670217346, 46728
  6835130552, 511607969 2710273635, 1618764870, 2506043623, 46728
Train 16, 13824759720, 444229650 8126586167, 1789580512, 3908553077, 87396
  13413586222, 442039792 8005957570, 1799130766, 3608454422, 87396
  13268855183, 434819998 7933138880, 1723300184, 3612370029, 87396
  13721455125, 442863286 8221694035, 1846210527, 3653509724, 87396
  13713059162, 431877823 8367220855, 1760778057, 3585024078, 87396
  13478051829, 435233350 8050562473, 1788058374, 3639391601, 87396
  13328868730, 429726471 8006697926, 1782177525, 3539956815, 87396
  13609567291, 429297367 8089610032, 1786087007, 3733826788, 87396
  13822880532, 433364955 8405137168, 1772379317, 3645324375, 87396
  13308229747, 436706188 7934141484, 1774284759, 3599757999, 87396
Train 32, 41011124899, 439375907 30247932368, 2543499619, 8219649156, 175754
  44020724453, 435012526 31933920368, 2596659467, 9490101444, 175754
  41078047278, 439858101 30324106875, 2463835983, 8290053371, 175754
  40705214820, 439824263 29861406515, 2562324756, 8281438626, 175754
  41366412238, 441804382 30478163553, 2549251825, 8338952228, 175754
  40952707875, 436851459 30130131012, 2586974443, 8235558371, 175754
  41466539540, 439972742 30499219387, 2544440964, 8422835141, 175754
  41480441215, 448951248 30363510903, 2470273413, 8646609936, 175754
  42084538383, 477098524 31026026553, 2571142239, 8487324377, 175754
  40676082152, 442398010 29820580115, 2511417483, 8344039922, 175754

Memory usage

 

Legend

Source model (KB): memory size of the source model
View model + RETE Network (KB): memory size of the view model and the EMF-IncQuery engine

 

 

Example Source model (KB) View model + RETE Network (KB)
Train 1, 47917 164175
  47715 167346
  50244 162089
  47196 162530
  51661 159461
  47199 162551
  47709 162091
  47713 162094
  47191 164388
  48270 159852
Train 2, 58918 106326
  59661 109397
  58187 110473
  58179 105849
  58918 105786
  58060 106108
  58907 109748
  58174 107122
  58057 109697
  58913 106300
Train 3, 80833 251903
  82160 242792
  82153 270047
  80993 250525
  81041 255030
  81862 242751
  81027 252238
  81844 250429
  82119 260514
  82154 251669
Train 4, 131667 216696
  133095 216401
  131654 194725
  133098 205545
  131646 229694
  134866 204242
  133108 204911
  133112 205230
  131672 217605
  132644 217385
Train 5, 219128 365446
  219156 399949
  219119 386020
  221104 341331
  219135 328297
  220393 357009
  221113 335394
  219124 351458
  221134 377458
  220539 377287
Train 6, 266829 860475
  266880 908782
  266865 902767
  253949 683224
  261000 634433
  267694 790160
  266848 660281
  268886 905946
  268838 681521
  256394 948193