Re: Calabash: cache the compiled pipeline

Hi Florent,

Op 17-11-2010 10:56, Florent Georges schreef:
>    I am using Calabash in a web application, which calls repeatedly
> the same pipeline (BTW, what is the idiomatic expression: to call
> a pipeline? to evaluate a pipeline?)  So I would like to cache
> the compiled representation of the pipeline, and instantiate only
> the runtime object for each invocation.
I've been doing the same process here repeatedly, with success.
>    It is not clear to me what object is usable as a "singleton"
> (more or less), like the Saxon Processor object.  I know I cannot
> use XPipeline as a shareable compiled object, but it is not clear
> what (nor whether) I can use instead.
At first I thought the "com.xmlcalabash.runtime.XPipeline" instance 
would suffice, but unfortunately, it uses the XProcRuntime instance for 
things like stacks, which makes it impossible to concurrently execute 
multiple pipelines with a shared Runtime. Using synchronized access to 
such a pipeline would work. In my setup, I've created an 
XProcRuntimePool, filled with XProcRuntimes (flyweight pattern), each 
runtime having references to a set of cached XPipeline's.

When a request comes in, a (synchronized) flyweight object is returned, 
possibly cached pipelines are found or a pipeline is compiled and 
subsequently executed. Quantitative load testing revealed a 80-150% 
faster execution, but obviously this depends greatly on the nature of 
the pipeline.

Problems I am having are:

1. Parallel execution of one pipeline by multiple threads
2. Dependency tracking (eg. referenced libraries might change, which 
should cause the cache to be invalidated, but currently I have found no 
way to do this, except by manually parsing the uncompiled xprocs).

Also note that, after executing a pipeline, you should call the reset() 
method on the XPipeline instance.

With regards,

Edwin de Jong



Met vriendelijke groet,

Edwin de Jong


Exxellence Group | www.exxellence.nl
Bezoekadres: Welbergweg 80-84 | 7556 PE Hengelo (ov.)
Postadres: Postbus 768 | 7550 AT Hengelo (ov.)
Tel. +31 (74) 25 94 008 | fax. +31 (74) 25 66 424

Received on Wednesday, 17 November 2010 10:37:57 UTC