Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Slow Ecore->Xtext serialization
Slow Ecore->Xtext serialization [message #668412] Thu, 05 May 2011 15:15 Go to next message
No real name is currently offline No real nameFriend
Messages: 3
Registered: May 2011
Junior Member
Hi all,

we have an issue when serializing an Ecore model (representing widgets in a UI) to a DSL formatted file using Xtext.

When making changes to the Ecore model (increasing the number of widgets in our model of the UI from one to two) which roughly double the size of the generated file, the time taken to serialize the model increases exponentially.

Profiling shows the majority of the time is taken up in Xtext's AbstractParseTreeConstructor.serialize(EObject object, AbstractToken currentToken, TreeConstructionReportImpl rep), where although the number of nodes in the model doubles (from one to two) the number of tokens visited goes up by a factor of ten. Similar exponential increases are seen increasing from two to three nodes, and so on.

Sorry if the above is vague, but if anyone had any thoughts on what the problem might be (perhaps with our grammar?) it'd be must appreciated. Also, please let me know if we can provide/look at any additional information to help debug this one,

Cheers,
Alasdair
Re: Slow Ecore->Xtext serialization [message #668434 is a reply to message #668412] Thu, 05 May 2011 15:42 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Alasdair,

the serializer in Xtext 1.* uses a backtracking algorithm to find a
suitable path through the grammar for your objects. This explains the
exponential runtime. Moritz is currently working on a new implementation
and we expect some serious performance improvements since the complexity
could be reduced.

There are ways to optimize your grammar for the Xtext 1.* algorithm,
e.g. avoid certain usage patterns. Long story short: please provide some
more information about your language.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 05.05.11 17:15, schrieb amaclean@temenos.com:
> Hi all,
>
> we have an issue when serializing an Ecore model (representing widgets
> in a UI) to a DSL formatted file using Xtext.
> When making changes to the Ecore model (increasing the number of widgets
> in our model of the UI from one to two) which roughly double the size of
> the generated file, the time taken to serialize the model increases
> exponentially.
> Profiling shows the majority of the time is taken up in Xtext's
> AbstractParseTreeConstructor.serialize(EObject object, AbstractToken
> currentToken, TreeConstructionReportImpl rep), where although the number
> of nodes in the model doubles (from one to two) the number of tokens
> visited goes up by a factor of ten. Similar exponential increases are
> seen increasing from two to three nodes, and so on.
>
> Sorry if the above is vague, but if anyone had any thoughts on what the
> problem might be (perhaps with our grammar?) it'd be must appreciated.
> Also, please let me know if we can provide/look at any additional
> information to help debug this one,
>
> Cheers,
> Alasdair
Re: Slow Ecore->Xtext serialization [message #668560 is a reply to message #668412] Fri, 06 May 2011 08:51 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 3
Registered: May 2011
Junior Member
Hey Sebastian,

thanks for the quick reply, much appreciated. I've attached a stripped out version of the grammar below. The case we're seeing the issue in is when a Widget contains another Widget (becoming worse with each additional level of Widget in the model).

Hope this stripped-back grammar is enough to go on; please let me know if it isn't,

Thanks,
Alasdair

grammar com.company.page.Page hidden(WS, ML_COMMENT, SL_COMMENT) 

import "platform:/resource/page-model/model/PageModel.ecore" 

import "http://www.eclipse.org/emf/2002/Ecore" as ecore

Model returns Model:
	{Model}
	widget=Widget
;

Widget returns Widget:
	{Widget}
	'Widget' typeName=ID
	(properties+=Property)*
	('{'
		(contents+=Widget (contents+=Widget)*)?
    '}')?;

Timestamp returns ecore::EDate:
	String_Value;

Property returns Property:
	{Property}
	typeName=ID '=' value=String_Value ('->' model=[Model|URI])?;

String_Value :
	STRING | ID | VALUE;

// Terminal rules

terminal ML_COMMENT	: '/*' -> '*/';
terminal SL_COMMENT 	: '#' !('\n'|'\r')* ('\r'? '\n')?;

terminal WS			: (' '|'\t'|'\r'|'\n')+;

terminal ID    : '^'? ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'-'|'.'|'0'..'9')*;

terminal VALUE : ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'&'|'/'|'%'|'.'|'-'|'é'|'è'|'à'|'ä'|'ö'|'ü'|'Ä'|'Ö'|'Ü'|'É'|'È'|'À'|'ç'|'ß')+;
 
terminal URI : "resource:///" ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'&'|'/'|'%'|'.'|'-')+;

terminal STRING	: '"' ( '\\' ('b'|'t'|'n'|'f'|'r'|'"'|"'"|'\\') | !('\\'|'"') )* '"';
Re: Slow Ecore->Xtext serialization [message #669741 is a reply to message #668560] Wed, 11 May 2011 11:06 Go to previous message
No real name is currently offline No real nameFriend
Messages: 3
Registered: May 2011
Junior Member
Hey there,

don't suppose you've (or someone else has) had any ideas on this at all? Is the grammar above enough to help solve the issue, or could I add some more information?

Cheers,
Alasdair
Previous Topic:\n in xtext
Next Topic:underscore separator in Xtext
Goto Forum:
  


Current Time: Tue Apr 23 06:10:43 GMT 2024

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

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

Back to the top