Validator context based [message #1849275] |
Tue, 11 January 2022 07:01 |
Alexandra Tritean 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 |
|
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 #1849344 is a reply to message #1849343] |
Thu, 13 January 2022 10:02 |
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.03701 seconds