Very slow Serializer (why is it using BacktrackingSemanticSequencer?) [message #891727] |
Mon, 25 June 2012 15:57 |
Michael Vorburger Messages: 103 Registered: July 2009 |
Senior Member |
|
|
Hello,
I'm not sure how relevant the overall context of what we're doing is to the question below, or if may even be the cause of the problem, so just in case: Basically we are reading (non-XMI) XML via XMLResource/GenericXMLResourceFactoryImpl (and replacing what I called name: scheme URIs by real Xtext proxies with your xtextLink_:: thingies - obtained "properly" from an IEObjectDescription from an IScope), and then adding a clone of the root object to an XtextResource, to then serialize it to the DSL.
Got this all working nicely, but finding the Serializer to be excruciatingly slow, i.e. SEVERAL MINUTES for a test model with about 70 property values & references... and looking like "forever" (probably just too slow; exponential?) when adding more.
Profiling shows 99.6% spent inside:
...Abstract(MyLang)SemanticSequencer.sequence_(MyTopLevelType)
org.eclipse.xtext.serializer.sequencer.ISemanticSequencer.createSequence
and then under that about 30% in com.google.common.collect.Lists.newArrayList(java.lang.Iterable).
I've debugged this and found the Abstract(MyLang)SemanticSequencer.sequence_(MyTopLevelType) genericSequencer to be a org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer - normal? Probably is "intended", because in DefaultRuntimeModule you say: binder.bind(ISemanticSequencer.class).annotatedWith(GenericSequencer.class).to(BacktrackingSemanticSequencer.class);
I've then tried to use the GenericSemanticSequencer instead, via:
@Override
@SuppressWarnings("restriction")
public Class<? extends ISemanticSequencer> bindISemanticSequencer() {
return GenericSemanticSequencer.class;
}
and that gets Serialization time from the Minutes down to 2s!
But... that's may be not how you intended this to be used?
There is probably a better way to do this?
Thanks a lot!
|
|
|
Re: Very slow Serializer (why is it using BacktrackingSemanticSequencer?) [message #891818 is a reply to message #891727] |
Tue, 26 June 2012 06:59 |
Moritz Eysholdt Messages: 161 Registered: July 2009 Location: Kiel, Germany |
Senior Member |
|
|
Michael Vorburger wrote on Mon, 25 June 2012 17:57
I've debugged this and found the Abstract(MyLang)SemanticSequencer.sequence_(MyTopLevelType) genericSequencer to be a org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer - normal? Probably is "intended", because in DefaultRuntimeModule you say: binder.bind(ISemanticSequencer.class).annotatedWith(GenericSequencer.class).to(BacktrackingSemanticSequencer.class);
yes, that is intended, because the BacktrackingSemanticSequencer can handle more use cases than the GenericSemanticSequencer. For example, it preservers the oder of elements in multi-alternatives and unordered groups.
The times that you're reporting sound quite horrible. Could you post your grammar? The most performance problems arise from grammars that are ambiguous for the serializer. Maybe I can find ways to structure the grammar in a better way - or handle certain scenarios more efficiently in the serializer.
Michael Vorburger wrote on Mon, 25 June 2012 17:57
I've then tried to use the GenericSemanticSequencer instead, via:
@Override
@SuppressWarnings("restriction")
public Class<? extends ISemanticSequencer> bindISemanticSequencer() {
return GenericSemanticSequencer.class;
}
and that gets Serialization time from the Minutes down to 2s!
But... that's may be not how you intended this to be used?
If that works for you... awesome! However, I may deprecate the GenericSemanticSequencer in the future since it has functional deficits.
Michael Vorburger wrote on Mon, 25 June 2012 17:57
There is probably a better way to do this?
Yes, you may override methods from Abstract(MyLang)SemanticSequencer.sequence_(MyTopLevelType) and supply your own implementation instead of delegating to the BacktrackingSemanticSequencer. In Abstract(MyLang)SemanticSequencer, there is a comment above every method that shows the grammar syntax that you have to comply with when you write out your tokens.
hth,
Moritz
|
|
|
Powered by
FUDForum. Page generated in 0.03077 seconds