xsl-list
[Top] [All Lists]

Re: [xsl] extrem performance break down

2012-12-12 08:04:20
On Wed, Dec 12, 2012 at 5:55 AM, Szabo, Patrick (LNG-VIE)
<patrick(_dot_)szabo(_at_)lexisnexis(_dot_)at> wrote:
Thanks a lot for your detailed answer.
I don't think I undersand your approach.
Why does it make a difference if i search the pattern first and put it in a 
vriable.  In  the end saxon will still have to search right ?



When the results of evaluating an expression are saved in a *global*
variable, this evaluation is done just once and the results are
available thereafter.

When the expression is in a match pattern, it is evaluated every time
the processor tries to determine if a given node is matched by that
template.

Therefore, the potential savings in time when using the variable
technique may be hundreds of times.


Cheers,
Dimitre




. . . . . . . . . . . . . . . . . . . . . . . . . .
Ing. Patrick Szabo
Developer
LexisNexis
A-1030 Wien, Marxergasse 25

mailto:Patrick(_dot_)Szabo(_at_)lexisnexis(_dot_)at
Tel.: +43 1 53452 1573
Fax.: +43 1 534 52 146

. . . . . . . . . . . . . . . . . . . . . . . . . .

-----Ursprüngliche Nachricht-----
Von: Michael Kay [mailto:mike(_at_)saxonica(_dot_)com]
Gesendet: Mittwoch, 12. Dezember 2012 11:17
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Betreff: Re: [xsl] extrem performance break down

I would have expected the first pattern to perform pretty badly, because of 
the use of [following::text()], which means that every time you look at a 
paragraph you also have to look at all the following text nodes.

But in your new pattern you are looking at all the preceding nodes of all the 
ancestors, and you are doing this for every element, not only for selected 
elements like p and ul.

You could probably get some improvement by reordering the predicates (the 
optimum order is some combination of putting the cheapest-to-evaluate 
predicate first, and putting the most-selective predicate first).

However, I would suggest a completely different approach. Whenever you have 
match patterns that need to search the document like this, it's often best to 
invert things: start by finding the nodes that match this complex condition 
and put this node-set in a global variable $special, then replace your 
pattern with

match="*[. intersect $special]"

Another point to be aware of with pattern matching in Saxon is that it will 
always work best if Saxon can determine that the pattern will only match 
elements of one particular element name. So you might well be better off 
breaking this into separate patterns that start

p[....]
ul[....]
span[.....]

Michael Kay
Saxonica

On 12/12/2012 08:14, Szabo, Patrick (LNG-VIE) wrote:
Hi,

I'm using Saxon-B 9.0.0.6 that comes with Oxygen 9 for profiling.
My Stylesheet is quite long so i don't wan't to post the whole thing but my 
problems seems to reside within one template anyway.

I have the following template:

<xsl:template match="*[self::p or 
self::ul][following::text()[starts-with(.,'Zum aktuellen Rechtsstand')] and 
ancestor::div[@class='comm.body'] and text()][1]" priority="20">
         ***something happens***
</xsl:template>

When i change the xpath to

<xsl:template match="*[not(ancestor-or-self::span[@class='heading' and 
count(preceding::span[@class='heading']) = 0])][self::p or self::ul or 
self::span[not(@class='heading' and count(preceding::span[@class='heading']) 
= 0)]][following::text()[starts-with(.,'Zum aktuellen Rechtsstand')] and 
ancestor::div[@class='comm.body'] and .//text()][1]" priority="20">
         **still same things happens** </xsl:template>

it adds 104 seconds to the execution time. Problem is i need to change it 
because otherwise it matches thing it's not supposed to.

Can anyone tell me what exactly I'm doing that is causing this performance 
break ?
As soo as i revert that one change execution time goes down again.

cheers


. . . . . . . . . . . . . . . . . . . . . . . . . .
Ing. Patrick Szabo
Developer
LexisNexis
A-1030 Wien, Marxergasse 25

mailto:Patrick(_dot_)Szabo(_at_)lexisnexis(_dot_)at
Tel.: +43 1 53452 1573
Fax.: +43 1 534 52 146

. . . . . . . . . . . . . . . . . . . . . . . . . .


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


<Prev in Thread] Current Thread [Next in Thread>