A list for the developers of CellML tools

Text archives Help


[cellml-dev] Very slow getPositionInXML function in VACSS


Chronological Thread 
  • From: ak.miller at auckland.ac.nz (Andrew Miller)
  • Subject: [cellml-dev] Very slow getPositionInXML function in VACSS
  • Date: Thu, 19 Jan 2012 11:50:42 +1300

On 19/01/12 06:58, Alan Garny wrote:
> Hi,
>
> I have some code which I use to validate a model
> <https://github.com/opencor/opencor/blob/master/src/plugins/misc/CellMLSupport/src/cellmlmodel.cpp#L137>
> and after testing it on a moderately big model (which has various
> warnings and errors), I was shocked to find out that my code is
> painfully slow.
>
> After a bit of debugging, the main culprit is the getPositionInXML
> function in the VACSS service
> <http://cellml-api.hg.sourceforge.net/hgweb/cellml-api/cellml-api/file/6bf200f297bd/VACSS/sources/VACSSImpl.cpp#l4726>
> which I call here
> <https://github.com/opencor/opencor/blob/master/src/plugins/misc/CellMLSupport/src/cellmlmodel.cpp#L173>
> and here
> <https://github.com/opencor/opencor/blob/master/src/plugins/misc/CellMLSupport/src/cellmlmodel.cpp#L193>
> (though the execution of my code went through the first call). The
> getValidityError function
> <http://cellml-api.hg.sourceforge.net/hgweb/cellml-api/cellml-api/file/6bf200f297bd/VACSS/sources/VACSSImpl.cpp#l49>
> which I use here
> <https://github.com/opencor/opencor/blob/master/src/plugins/misc/CellMLSupport/src/cellmlmodel.cpp#L158>
> is also slow but not ?as bad? as getPositionInXML.
>
> Anyway, this all stems from the fact that I want/need to know exactly
> where, in a CellML file, an error/warning occurred. I may not have
> approached the problem in the best way, so any suggestion would be much
> appreciated. What is certain, though, is that there is loads of room for
> improvement in the aforementioned functions?

Hi Alan,

getPositionInXML needs to traverse the entire DOM to find the position
of the desired target variable for each call - it does not cache
position information so it re-does the calculation for each call from
the start of the document.

If you just want to take a user to an element when they click on it, it
would be better to use the element itself rather than the position to
find that element.

I'd suggest trying to call it as late as possible so you aren't calling
it for a large batch of elements.

Because the DOM is 'live', caching positions in the DOM is difficult
(for example, it is valid to perform a validation, then insert an
element into the DOM, then look up a position in the DOM - and the
position is supposed to reflect the new location). We could make the DOM
cache positions with a serial number, and change the global serial
number any time any change is made to any DOM; however, a better
approach might be a new service designed to efficiently label positions
in a particular unchanging version of the document, so that large
batches of positions can be found.

Best wishes,
Andrew

>
> Cheers, Alan.
>
> *Dr Alan Garny*
>
> University of Oxford, Department of Physiology, Anatomy & Genetics
>
> Sherrington Building, Parks Road, Oxford, OX1 3PT, England
>
> http://cor.physiol.ox.ac.uk/ ? http://www.opencor.ws/
>
> *_Note:_*I have relocated to INRIA in France and you should email me at
> alan.garny at inria.fr <mailto:alan.garny at inria.fr> from 1 February 2012
> onwards?
>
> Asclepios Research Project
>
> INRIA Sophia Antipolis
>
> 2004, route des Lucioles - BP 93
>
> 06902 Sophia Antipolis Cedex
>
> *Phone:*+33 49238 7789
>
>
>
> _______________________________________________
> cellml-tools-developers mailing list
> cellml-tools-developers at cellml.org
> http://lists.cellml.org/mailman/listinfo/cellml-tools-developers





Archive powered by MHonArc 2.6.18.

Top of page