When I had a play with this, using tail() or subsequence() instead of position() seemed to work around the issue.

On 8 Jan 2014 16:04, "Michael Kay" <mike@saxonica.com> wrote:
>
> I'm working on it.
>
> The performance regression actually occurs between 9.3 and 9.4, which surprises me a little as this area was redesigned between 9.4 and 9.5. That probably means that the regression isn't in that area.
>
> I don't think it's anything to do with tail recursion. It's almost certainly about whether or not $pSeq[position() gt 1] makes a copy of the sequence $pSeq.
>
> Michael Kay
> Saxonica
>
>
> On 8 Jan 2014, at 15:20, Dimitre Novatchev <dnovatchev@gmail.com> wrote:
>
> > Other people have reproduced the issue, so it isn't just my
> > imagination. Hope this would be fixed, or some existing
> > transformations would suddenly start running hundred times slower :(
> >
> > Cheers,
> > Dimitre
> >
> > On Sun, Jan 5, 2014 at 8:22 PM, Dimitre Novatchev <dnovatchev@gmail.com> wrote:
> >> With Saxon 8.1.08 the following transformation takes 0.2 seconds.
> >> With Saxon 9.5.1.3 it takes 28 seconds -- 140 times more time:
> >>
> >>
> >> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> >> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> >> xmlns:my="my:my">
> >> <xsl:output omit-xml-declaration="yes" indent="yes"/>
> >>
> >> <xsl:template match="/">
> >>   <xsl:sequence select="my:sumSquares(1 to 100000, 0)"/>
> >> </xsl:template>
> >>
> >> <xsl:function name="my:sumSquares" as="xs:double">
> >>  <xsl:param name="pSeq" as="xs:double*"/>
> >>  <xsl:param name="pResult" as="xs:double"/>
> >>  <xsl:sequence select=
> >>   "if(not($pSeq[1]))
> >>      then $pResult
> >>      else
> >>        my:sumSquares($pSeq[position() gt 1],
> >>                      $pResult + $pSeq[1] * $pSeq[1])
> >>   "/>
> >> </xsl:function>
> >> </xsl:stylesheet>
> >>
> >> --
> >> Cheers,
> >> Dimitre Novatchev
> >> ---------------------------------------
> >> Truly great madness cannot be achieved without significant intelligence.
> >> ---------------------------------------
> >> To invent, you need a good imagination and a pile of junk
> >> -------------------------------------
> >> Never fight an inanimate object
> >> -------------------------------------
> >> To avoid situations in which you might make mistakes may be the
> >> biggest mistake of all
> >> ------------------------------------
> >> Quality means doing it right when no one is looking.
> >> -------------------------------------
> >> You've achieved success in your field when you don't know whether what
> >> you're doing is work or play
> >> -------------------------------------
> >> To achieve the impossible dream, try going to sleep.
> >> -------------------------------------
> >> Facts do not cease to exist because they are ignored.
> >> -------------------------------------
> >> Typing monkeys will write all Shakespeare's works in 200yrs.Will they
> >> write all patents, too? :)
> >> -------------------------------------
> >> I finally figured out the only reason to be alive is to enjoy it.
> >
> >
> >
> > --
> > Cheers,
> > Dimitre Novatchev
> > ---------------------------------------
> > Truly great madness cannot be achieved without significant intelligence.
> > ---------------------------------------
> > To invent, you need a good imagination and a pile of junk
> > -------------------------------------
> > Never fight an inanimate object
> > -------------------------------------
> > To avoid situations in which you might make mistakes may be the
> > biggest mistake of all
> > ------------------------------------
> > Quality means doing it right when no one is looking.
> > -------------------------------------
> > You've achieved success in your field when you don't know whether what
> > you're doing is work or play
> > -------------------------------------
> > To achieve the impossible dream, try going to sleep.
> > -------------------------------------
> > Facts do not cease to exist because they are ignored.
> > -------------------------------------
> > Typing monkeys will write all Shakespeare's works in 200yrs.Will they
> > write all patents, too? :)
> > -------------------------------------
> > I finally figured out the only reason to be alive is to enjoy it.
> >
> > ------------------------------------------------------------------------------
> > Rapidly troubleshoot problems before they affect your business. Most IT
> > organizations don't have a clear picture of how application performance
> > affects their revenue. With AppDynamics, you get 100% visibility into your
> > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
> > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> > _______________________________________________
> > saxon-help mailing list archived at http://saxon.markmail.org/
> > saxon-help@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> saxon-help@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/saxon-help