processi

about processes and engines

faster OpenWFE

Let me start with a quote from Tony Hoare : “premature optimization is the root of all evil”. The wikiquote page has other gems from him.

Nicolas benchmarked his embedded OpenWFE and asked me to reduce the parsing time of process definitions, he had identified it as a major bottleneck. The initial releases of OpenWFE cached the process definitions, but that implementation was awkward and the caching came in the way of users in process design environments, they wanted their modified process definitions to be immediately available, other problems were also induced by this initial optimization.
Nicolas’ tests are against the latest releases of OpenWFE which do not contain any optimization on the process definition parsing front.

The solution was simply to cache any XML being loaded into OpenWFE from files (URLs) or strings. As soon as a request for something already parsed once arrives, the cache replies by cloning the corresponding JDOM XML tree. A short process definition could take 200ms to be turned into a JDOM document instance from its file, cloning the [whole] JDOM tree takes usually less than 1 ms.
Of course, if the file or the URL yields a newer version, it will be parsed (and then cached).

Nicolas’ benchmark times thus got cut in two.

When the initial optimization got removed, the remaining code was slower but could evolve with more freedom (a point for aspect-oriented programming).
The new optimization requested by Nicolas occurs in the OpenWFE library in charge of XML loading, whereas the initial one occured in the engine itself when loading new XML process definition. The engine’s code doesn’t include caching concerns (as before this new optimization).

This change is part of the upcoming OpenWFE 1.7.2 (since its pre4).

(Yes, I use JDOM and I’m happy with it).

Written by John Mettraux

August 8, 2006 at 11:34 am

Posted in dev, openwfe

%d bloggers like this: