JModelica 1.17 takes an unfeasibly long time to build with JastAdd 2.2.2. This is caused primarily by the
Grammar.parentMap() attribute in JastAdd and its use in inherited equation checking, but there are some contributing factors:
Grammar.parentMap()is not memoized, because of the issues described in #268.
- The time complexity of
parentMap()is exponential in the number of AST classes.
- JModelica uses more AST types than any other JastAdd project I'm aware of with 640 AST classes and many other types.
parentMap()attribute is called during inherited attribute equation checking (looking for missing equations), and it is called very often when building JModelica 1.17 which has 437 inherited attribute declarations.
Possible solutions to the slow build:
- Disable inherited equation checking using the
--inhEqCheck=falseoption. This is a workaround that makes the build complete in a reasonable time right now, but it's not a good solution.
- Rewrite inherited equation checking use a temporary copy of the
parentMap()attribute. This is an ugly solution.
- Use a separate, memoized, attribute in inherited equation checking. This is an ugly solution, but easy to implement.
- Remove side effects so that
parentMap()can be memoized safely. This is the best solution, but requires lots of work to implement.