atlanmod / Mogwai

Automatic translation from OCL to Gremlin
10 stars 6 forks source link

Generated code performance vs Dynamic groovy #31

Open gdaniel opened 7 years ago

gdaniel commented 7 years ago

Is it interesting to generate native code that is more complex but faster than dynamic Groovy implementation?

For example: collect(ref)->isEmpty is translated into getRef(ref).asList().isEmpty(). This implementation is not efficient: getRef returns an Iterable that is filled from the database. If we put it in a list we force the database to load everything just to check if there is at least one element in the list.

Another approach is to dynamically add Iterable.metaClass.isEmpty to the init Groovy script, with an optimized implementation: !this.hasNext(). But Groovy dynamic dispatch is very slow, especially for closure-based methods.

For now I use the first solution, but I don't think it is the most interesting in the general case, need to to some experiments.

gdaniel commented 7 years ago

refs #33