Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 14:10 Go to next message
Marc Missing name is currently offline Marc Missing nameFriend
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 #894012 is a reply to message #893796] Fri, 06 July 2012 11:53 Go to previous messageGo to next message
Marc Missing name is currently offline Marc Missing nameFriend
Messages: 38
Registered: March 2011
Member
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 13:10 Go to previous messageGo to next message
Marc Missing name is currently offline Marc Missing nameFriend
Messages: 38
Registered: March 2011
Member
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 09:01 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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 13:03 Go to previous messageGo to next message
Marc Missing name is currently offline Marc Missing nameFriend
Messages: 38
Registered: March 2011
Member
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 09:51 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
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: Thu Mar 28 14:37:58 GMT 2024

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

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

Back to the top