Hemant Bist wrote:
Hi,
We are using Xalan-C++ version 1.10 in an app which spends almost all
its time in doing xsl transfomations. I am looking to optimize its
performance if possible.
The app applies a compiled stylesheet repeatedly on input "strings" that
are about 5k long and produce and xml output that is also about 5k long.
1) The input string looks like this <<?xml version="1.0"><dummyroot>LONG
XMLENCODED STRING</dummy root>
2) stylesheet converts the input to a "proper" xml output". The logic in
style sheet is bunch of if and substr statements. like this
.... <!-- sample snippet from style sheet -->
<AccountNumber>
<xsl:value-of
select="normalize-space(substring(.,2058,10))"/>
</AccountNumber>
<xsl:if
test="string-length(normalize-space(substring(.,9,12)))>0">
<MyIdentifier>
<xsl:value-of
select="normalize-space(substring(.,9,12))"/>
</MyIdentifier>
</xsl:if>
3) This is running on sun solaris and a typical analyzer output shows
xalanc_1_10::XalanVector<unsigned
short,xalanc_1_10::MemoryManagedConstructionTraits<unsigned short>
>::insert(unsigned short*,const unsigned short*,const unsigned short*)
takes 27.109 (76.33%) of User time. which is being called from
xalanc_1_10::FunctionSubstring::execute(xalanc_1_10::XPathExecutionContext&,xalanc_1_10::XalanNode*,const
xalanc_1_10::XObjectPtr,const xalanc_1_10::XObjectPtr,const
xalanc_1_10::XObjectPtr,const xercesc_2_7::Locator*)const
One of the problems is your stylesheet is creating lots of strings. Is
it possible for you to do normalize-space once, then use the substring
function on the normalized string? That could be tricky, given you're
using hard-coded indices, but it's something to explore.
You might also consider using the substring-after or substring-before
functions on the normalized string, if there are unique substrings you
can use to break up it up.
Finally, please make sure you're using an optimized build. It looks like
your compiler isn't inlining as much as it could. You might try playing
with the default optimization level the runConfigure script uses. If
you're using GCC, try increasing the optimization level to -O3.
Dave