Home » Modeling » VIATRA » Deep Copy of Engine, Resource and Pattern Matches(Can we make a deep copy of the engine, resources and pattern matches?)
Deep Copy of Engine, Resource and Pattern Matches [message #1832811] |
Fri, 25 September 2020 12:55 |
Hans van der Laan Messages: 34 Registered: February 2020 |
Member |
|
|
Hey,
Is it possible to make a deep copy of the engine, the resource and all found pattern matches?
I'm currently exploring how I could measure the performance of my VIATRA-based solution. I would like to do it similar to the Train Benchmark [1]. Namely, load the model, load the queries and then simulate use case scenarios during which the model gets iteratively transformed/rechecked.
However, the initial read/check of my model takes quite a lot of time. The model is based upon real data and therefore quite complex. It would be ideal if I could make a deep copy of the engine, the resources and all found pattern matches. Then, I would only have to read/check the model once and I can use a copy for all use case scenario simulations. Is something of the sorts possible?
- Hans
[1] The Train Benchmark: cross-technology performance evaluation of continuous model queries
[Updated on: Fri, 25 September 2020 13:07] Report message to a moderator
|
|
|
Re: Deep Copy of Engine, Resource and Pattern Matches [message #1832815 is a reply to message #1832811] |
Fri, 25 September 2020 13:17 |
Zoltan Ujhelyi Messages: 392 Registered: July 2015 |
Senior Member |
|
|
Hi Hans,
the short answer is that there is no way to do a "deep copy" of an existing engine in VIATRA.
We were thinking in the past about various ways to make some or all parts of the engine reusable but we were thinking about another direction: save the indexes in a way that makes it possible to reinitialize them without opening/traversing the model (even if the application was closed instead), but this comes with a very different set of challenges (e.g. how to reference EMF model elements that are reusable; how to make sure that all data structures inside the VIATRA query engine is serializable, etc.). Conceptually this seemed doable but we never did have the resources to implement it.
Another alternative you could try (even if it is a bit different) to check is the snapshot models used by the VIATRA query test framework [1]: it can be used to save a result of VIATRA query matches in an EMF metamodel, and you might be able to work with this. However, this metamodel still refers to model elements as EMF references, so you still have to open the models to process the query snapshots, but you could avoid initializing the index. Of course, this solution will not work for the transformation/re-check scenarios, as it is a static snapshot of the query results.
To be more constructive, if you _really_ want to reuse the original state, maybe you could implement the transformation as an undoable model transformation, and after the recheck step is done, simply revert all changes. However, you should be very careful when doing this as if you are reusing existing elements, both execution times and memory usage might change (e.g. depending on how many times garbage collection needs to run). So my suggestion would be to keep the executions separate to make the measurements repeatable and comparable.
Hope this helps,
Zoltán
[1] https://www.eclipse.org/viatra/documentation/query-tools.html
|
|
| |
Re: Deep Copy of Engine, Resource and Pattern Matches [message #1833502 is a reply to message #1832817] |
Thu, 15 October 2020 07:41 |
Hans van der Laan Messages: 34 Registered: February 2020 |
Member |
|
|
Hey Zoltán,
CRIU works!!
There is a small kernel bug which makes it so that it can not be used on the most recent kernel [2]. Instead, you have to backport Linux to the
LTS kernel 5.4.70-1-lts. People are working on patching the kernel.
To be honest, I'm flabbergasted by the results. I have not measured the exact time, however restarting the JVM with my initialized VIATRA engine feels almost
instantaneous. This drastically speeds up my benchmarks, as now instead of waiting ~2m per test case for the engine to initialize I can initialize the engine once,
save the process and restore the engine for every test case. I've also managed to automatize this with python.
For those interested, the commands to get CRIU working with Java:
step 1: start the engine:
java -XX:-UsePerfData -jar ./engine.jar
step 2: dump the process
criu-ns dump -t $(pidof java) -o dump.log --shell-job
step 3: restore the process
criu-ns restore -o restore.log --shell-job
The criu-ns script can be found in the scripts folder of CRIU's GitHub [3]. Please note that you're not limited to restoring the process once, nor limited to having one
restored version of the process running at the same time. You can have multiple restored processes running in parallel. For those interested, I will release my benchmark
code with the results of my master thesis.
Kind regards,
Hans
[1] https://www.criu.org/Main_Page
[2] https://github.com/checkpoint-restore/criu/issues/1232
[3] https://github.com/checkpoint-restore/criu/
[Updated on: Thu, 15 October 2020 08:16] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sun Dec 08 09:35:54 GMT 2024
Powered by FUDForum. Page generated in 0.05146 seconds
|