JModelica build is too slow

Issue #269 resolved
Jesper Öqvist created an issue

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.
  • The 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.

Memoization was removed from parentMap() in commit b494ab53ef6b741dbaaabe30c6a6bd84c83fe058 because of the reasons discussed in #268. Memoization was causing the test case inh/nta_04p to fail.

Possible solutions to the slow build:

  • Disable inherited equation checking using the --inhEqCheck=false option. 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.

Comments (2)

  1. Jesper Öqvist reporter

    I only tested building the Compiler/ModelicaCompiler component of JModelica. There are probably more classes and attributes in the OptimicaCompiler component.

  2. Jesper Öqvist reporter

    Make Grammar.parentMap() memoized again

    Thanks to recent commits making synthesized NTA collection declarative, it is now possible to make Grammar.parentMap() memoized again. This should improve inherited equation checking performance.

    fixes #269

    → <<cset c198f006f8c0>>

  3. Log in to comment