Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » [acceleo] Question on OCL cache and standalone + thread
[acceleo] Question on OCL cache and standalone + thread [message #893796] Thu, 05 July 2012 10:10 Go to next message
Eclipse UserFriend
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 #894012 is a reply to message #893796] Fri, 06 July 2012 07:53 Go to previous messageGo to next message
Eclipse UserFriend
Ok... Did some first try, and it seems that something is not thread-safe... I get a strange error at runtime :
java.lang.UnsupportedOperationException: Operation substring(Integer) is undefined on type null.
	at org.eclipse.acceleo.engine.internal.environment.AcceleoLibraryOperationVisitor.getExceptionOperationCallFailed(AcceleoLibraryOperationVisitor.java:1046)


I don't have this error when running everything sequentially in one thread... I'll continue to dig this, but I've already tried to deep copy the model without luck.
Re: [acceleo] Question on OCL cache and standalone + thread [message #894038 is a reply to message #894012] Fri, 06 July 2012 09:10 Go to previous messageGo to next message
Eclipse UserFriend
For some reason, sometimes, I can get something working, but only when running the application within eclipse. And even in this case, execution time is greater when using threads. I guess there is some lock bottleneck somewhere that causes serialization...

Any hint still welcome.
Re: [acceleo] Question on OCL cache and standalone + thread [message #894170 is a reply to message #894038] Sat, 07 July 2012 05:01 Go to previous messageGo to next message
Eclipse UserFriend
Hi

OCL is not thread safe. Probably the same for Acceleo.

For OCL, you might have some success if you populate all the caches
while executing a high coverage portion of your activity on one thread,
before continuing execution on many threads. No guarantee.

Regards

Ed Willink


On 06/07/2012 14:10, Marc Mising name wrote:
> For some reason, sometimes, I can get something working, but only when
> running the application within eclipse. And even in this case,
> execution time is greater when using threads. I guess there is some
> lock bottleneck somewhere that causes serialization...
>
> Any hint still welcome.
Re: [acceleo] Question on OCL cache and standalone + thread [message #894770 is a reply to message #894170] Tue, 10 July 2012 09:03 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the clarification!
Marc
Re: [acceleo] Question on OCL cache and standalone + thread [message #900273 is a reply to message #894770] Mon, 06 August 2012 05:51 Go to previous message
Eclipse UserFriend
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
Previous Topic:[Acceleo] how to input multiple models URGENT!!
Next Topic:[XPAND] Update of XPAND Content Assistant when changing Metamodel
Goto Forum:
  


Current Time: Mon Jul 07 00:41:03 EDT 2025

Powered by FUDForum. Page generated in 0.07701 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top