Tuesday, June 7, 2011

Acceleo query cache

Some of our users have been bit by the fact that Acceleo caches the result of Query invocations, returning the very same result each time a given query is called. These users often came with the same two questions : "why?" and "Can this cache be disabled in my case?".

The answer to the first has always been and will remain the same : Acceleo is an implementation of the OMG's MOFM2T 1.0 specification, and this specification tells us that
  • A query is required to produce the same result each time it is invoked with the same arguments.
That is the reason we decided to cache the result : in order to return that same result each time the query is called, without re-evaluating it.

The answer to the second, however, changes with the 3.1.0 release of Acceleo : even though we strive to be as close as possible to the specification, there are times where this caching of the query return values is not desirable : it can be really costly memory-wise, it could be a call to a Java method that has random results, it could be a query which return value changes according to variable states that are not passed as parameters... That was possible through programmatic calls in 3.0.2, but we've decided to make that preference available through the UI in 3.1.0 :


The next step is to have the specification evolve in order to be able to disable the query cache "per-query" instead of globally but... that's another story :).

6 comments:

  1. Hi,

    what are using to make the query?
    EMFQuery? EMFQuery2? another things?

    Do you have benchmark

    Regards,

    ReplyDelete
  2. A quick comment on the UI. The label of a checkbox should indicate what the checked state means, while here they indicate an action. I suggest rephrasing to "Cache the evaluation of queries" or "Use query evaluation cache", and similar for the other checkbox.

    ReplyDelete
  3. Hi,

    wouldn't introducing an annotation to disable the caching of a particular query be a better solution? As opposed to the global preference approach?

    Kind regards,
    Niels Brouwers.

    ReplyDelete
  4. @scratsh : Acceleo is a model to text tool implementing an OMG specification, with its own syntax and semantics. "Query" in the Acceleo syntax is an OCL expression, coded in Java; neither EMF Query or EMF Query2, but our own implementation of our specification.

    ReplyDelete
  5. @Hallvard : We have hover popups to better indicate what each checkbox means, but indeed your rephrasing propositions seem better that our long labels... These will probably be rephrased in 3.1.1 :).

    ReplyDelete
  6. @Niels : Enabling the query through either an annotation or a custom syntax element is our goal and what we hope to have, ultimately. Yet we'd like to make the OMG specification evolve before we introduce such a change in the syntax.

    ReplyDelete