Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Validator context based
Validator context based [message #1849275] Tue, 11 January 2022 07:01 Go to next message
Alexandra Tritean is currently offline Alexandra TriteanFriend
Messages: 37
Registered: March 2020
Member
Hello and a Happy New Year,

I have a curiosity regarding a way in which the validator of a grammar can be improved from a performance point of view.
I was wondering if it's possible to apply only those checks that are relevant for the context in which the editing is done.
For example, if I have two types of entities, to determine in which type of entity the change was made and apply only those relevant checks instead of having all of the checks of the grammar running. I'm not sure if this makes sense or even if it's worth it to do something like this.
A little bit of context, one of the files ended up with 55k lines and we have around 60 checks, so every little change has quite an impact.
I've already set the type of some of the checks to expensive, but I was looking into other ways in which the performance can be improved on this side.

Thank you,

Alexandra

[Updated on: Tue, 11 January 2022 07:01]

Report message to a moderator

Re: Validator context based [message #1849277 is a reply to message #1849275] Tue, 11 January 2022 07:18 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

I don't think that this is possible. When one file is changed, the whole is resource is parsed and validated. The typical way is to declare non-trivial validation rules to NORMAL or EXPENSIVE. Only leave FAST for those rules that really should be applied on editing!

Note that 55k Xtext resources are not typical anyway, can't you split this? You don't try to create 55k Java files also. If your language does not support this, you might consider adding such a feature.

Files of that size may exist, I know. Some use cases are generated code. In cases that there are manually maintained files of that size, the implementors do performance optimizations like custom lexing, reduced validation etc.

However, I fear there is nothing the framework could do to support your use case out-of-the-box.
Re: Validator context based [message #1849278 is a reply to message #1849277] Tue, 11 January 2022 07:32 Go to previous messageGo to next message
Alexandra Tritean is currently offline Alexandra TriteanFriend
Messages: 37
Registered: March 2020
Member
You're right, having a 55k Xtext resource is not common and I'm completely sure that the best solution would be to do a split, but since adding such a feature might be more complex and time consuming, I was fantasizing about a 'short term' solution.

Thank you for your answer. :)
Re: Validator context based [message #1849279 is a reply to message #1849278] Tue, 11 January 2022 07:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14263
Registered: July 2009
Senior Member
do you know what is slow about your validations?

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Validator context based [message #1849280 is a reply to message #1849279] Tue, 11 January 2022 08:00 Go to previous messageGo to next message
Alexandra Tritean is currently offline Alexandra TriteanFriend
Messages: 37
Registered: March 2020
Member
I was looking with the JProfiler and the 'hot spots' seem to be in the validations that are using
- either the iterator
org.eclipse.xtext.xbase.lib.IteratorExtensions.toList(java.util.Iterator)
org.eclipse.xtext.xbase.lib.IterableExtensions.size(java.lang.Iterable)
- either some parsers (int/float from java.lang)
so I don't think there is much that I can do from this perspective.
Re: Validator context based [message #1849281 is a reply to message #1849280] Tue, 11 January 2022 09:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14263
Registered: July 2009
Senior Member
the question is if you have quadratics there an can optimize by putting the validation on the roots

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Validator context based [message #1849343 is a reply to message #1849281] Thu, 13 January 2022 09:55 Go to previous messageGo to next message
Alexandra Tritean is currently offline Alexandra TriteanFriend
Messages: 37
Registered: March 2020
Member
Excuse my ignorance, but I'm not very sure what you mean by that.

Would it be more efficient to do the checks on 'one level higher' for example? Or to do the checks on the container of a collection of objects instead of every object?
Re: Validator context based [message #1849344 is a reply to message #1849343] Thu, 13 January 2022 10:02 Go to previous message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Yes, this is what Christian meant. It might be more efficient to implement validation on the containers. You might be able to evaluate some context for the check that you need for each instance.

But especially within your validation rules watch out where you do loops. Try to reduce to a minimum.

Note that IterableExtensions#size() is expensive, depending on the Iterable's size. Sometimes you might only want to check if some iterable is empty or not.
Previous Topic:Log4j 1.x updates to Log4j2
Next Topic:Xtext with Java as code generator
Goto Forum:
  


Current Time: Wed May 25 17:26:10 GMT 2022

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

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

Back to the top