-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[performance] can we avoid loading grammar generator for every reified type? #1882
Comments
Do we need this? It will be a very impactful fix including the duplication of quite some code. I'd rather wait for the compiled version which does not even have this as a run-time feature because it is a compile-time constant. |
Or in other words: the compiler avoids this, so we could say "fixed" ;-) |
Well, it's a thing I'm seeing at our customers, that all the effort of removing parsergenerators being loaded is hurt at a different point where we trigger So I was wondering: can we move that loading of the grammar inside the if for only the |
Ah I see. Type reification is a complex operation which includes resolving all the imported and extended modules, finding out which types are dependent on each other through grammars and data-types and aliases, etc. etc. If |
The grammar collection code can only be avoided if we know that the reified type literal does not refer to any non-terminals. Such an analysis is expensive, because it depends on all the declarations in all the visible scopes, and it would be additive in the case where indeed there is an non-terminal present (like in the case of a TModel). So I don't see a way of avoiding this code and having a positive impact on performance without re-implementing the grammar collection code in Java. This is a big piece of complex Rascal code so I don't think we'll be able to do this. And this entire cost will go away with the compiler. |
If we type in the following:
we see that the parser generator is loaded before the
#X
(aka reified type) is calculated. Is it possible to tune that? Looking at this section:rascal/src/org/rascalmpl/semantics/dynamic/Expression.java
Lines 2362 to 2368 in 7f48fd7
It looks like only
value
is excluded, but lower down we already dispatch on if it's a grammar type:rascal/src/org/rascalmpl/semantics/dynamic/Expression.java
Lines 2372 to 2377 in 7f48fd7
I might be missing something, but if the type to be reified is not a grammar type, do we need to load the parser generator to calculate the grammars in the module? Or is this due to the nested grammars that might be in there? like
#list[A]
whereA
is a lexical?The text was updated successfully, but these errors were encountered: