[acceleo] Question on OCL cache and standalone + thread [message #893796] |
Thu, 05 July 2012 14:10 |
Marc Missing name Messages: 38 Registered: March 2011 |
Member |
|
|
Hi !
I'm using acceleo in a standalone application. It works great, but it is really slow. I guess I can't do much if I don't want to change my templates.
Is it correct to assume that queries in acceleo are cached ?
Than, still because my app is a bit slow, I want to generate files in parallel, as I have a lot of files to generate (and nearly everything can be in //).
I guess it would be hard to introduce parallel template invocation inside a template (would be great though!)
Is it safe to launch 2 acceleo generation using a different @main template, but sharing some common template, on the same model ?
Same question, but with the same template, simply a different entry in the model ? Maybe it's not clear... My model is a set of object P. Currently, I use something like:
List<P> myPs;
...
for (P p : myPs) {
...
generator = new GeneratePackage(p, outputdirF, args);
generator.doGenerate(new BasicMonitor());
}
I guess I could save something by passing the list in a template and then using a for loop in acceleo. But what if I could use parallel calls to doGenerate() methods ?
|
|
|
|
|
|
|
Re: [acceleo] Question on OCL cache and standalone + thread [message #900273 is a reply to message #894770] |
Mon, 06 August 2012 09:51 |
|
Hi Marc,
Acceleo is not currently thread-safe in itself. We do plan to parallelize the generation of each [file] block, but that is low-priority.
However, the problem you have here can be greatly improved if I'm reading it correctly.
for (P p : myPs) {
...
generator = new GeneratePackage(p, outputdirF, args);
generator.doGenerate(new BasicMonitor());
}
You're launching the generator n times... which really is the reason of your slowdowns. That means you will initialize everything (for both OCL and Acceleo) n times instead of re-using the already-initialized classes and caches.
The good practice (http://www.obeonetwork.com/page/acceleo-best-practices) is to have a single entry point for your generation, a unique "mtl" files that takes your model as input and does the loops directly from Acceleo. In your case :
[template public main(m : Model)]
[comment @main/]
[for (p: Package | m.ownedPackages)]
[generatePackage(p)/]
[/for]
[/template]
and calling "main" instead of iterating over your packages in java and calling directly "generatePackage" on each.
Laurent Goubet
Obeo
|
|
|
Powered by
FUDForum. Page generated in 0.02906 seconds