473,597 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Performance of XSLT

Hallo,

there were some posts about this, but nothing I could find useful.
I have a large XML file (80MB) and need certain information out of it.
I though I could use XSLT with an fairy simple transformation:
....
<xsl:for-each select="/values/STRING/item[I=10]">
<tr class="own">
<td><xsl:valu e-of select="A"/></td>
<td><xsl:valu e-of select="B"/></td>
</tr>
</xsl:for-each>
<tr class="header">
<td><xsl:valu e-of select="format-number(sum(/values/STRING/item/A),
'###,###')"/></td>
<td><xsl:valu e-of select="format-number(sum(/values/STRING/item/B),
'###,###')"/></td>
</tr>
....
but the performance is more than miserable (5-6 hours at least!)
How do I solve this problem? Is there a fast XML-parser, which can do
the work? After all its just a straight-forward read of a file.

Kind Regards,
Chris

Feb 22 '07 #1
9 2179
* starlight wrote in comp.text.xml:
>How do I solve this problem? Is there a fast XML-parser, which can do
the work? After all its just a straight-forward read of a file.
Well, which processor did you use up until now? Generally speaking, you
might want to try MSXML and Saxon; Saxon and xsltproc also allow you to
do some tracing and performance analysis, if you reduce the input size
and let them analyze the transformation, you might find why its so slow.
Other than that, you've shown too little of the transformation and the
document to give better advise.
--
Björn Höhrmann · mailto:bj****@h oehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Feb 22 '07 #2
On Feb 22, 11:17 am, "starlight" <hristoma...@ya hoo.com>
wrote:
there were some posts about this, but nothing I could
find useful. I have a large XML file (80MB) and need
certain information out of it. I though I could use XSLT
with an fairy simple transformation:
[simple XSLT fragment]
but the performance is more than miserable (5-6 hours at
least!) How do I solve this problem? Is there a fast
XML-parser, which can do the work? After all its just a
straight-forward read of a file.
What XSLT processor are you using? I ran a quick test on a
~50MB test file filled with junk data (with simple and
regular XML structure), copying one tenth of the records
with predicates and summing the values of all numeric
fields, using xsltproc (libxslt). It took about ten
seconds.

I think it has to be one of the three possible problems:

- either your XSLT processor is really slow;
- or the stuff you're doing is quite a bit more complex
than your example suggests;
- or you're doing something very inefficiently.

--
Pavel Lepin

Feb 22 '07 #3
XSLT is a programming language. Like any language, its performance
depends on a combination of how well your code is written and how well
the processor can optimize it.

Your example, as written, scans through the entire document three times
-- once in the for-each, then twice in calculating the sums. You didn't
show the context, but if the sequence you've shown us was itself
embedded in another loop...

Also: Because XSLT supports random access to a document's contents, it
normally operates by reading the entire document into memory and
processing it there. With larger documents that can drive you into
swapping, at which point your PC's performance immediately falls through
the floor. Different processors use different in-memory models which can
exacerbate or reduce this problem. (A few, such as the custom XSLT
processor in the Datapower/IBM "network appliance", can perform some
streaming analysis and *seriously* reduce the read-process-write
overhead for a subset of XSLT; I'm not sure whether their algorithm
would stream this particular example or not.)

Outside of trying different processors in a search for one that's
happier with your example (I'd try Apache Xalan, but I'm biased...), the
thing I'd suggest is that you consider hand-coding this as a SAX
application. The example you've shown us, if that's all you're doing,
could indeed be fully streamed and would then be speed-limited only by
the parser, the serializer, and the rate at which you can get data into
and out of it... and ought to deliver the kind of performance you're
looking for. (Again, being biased, I'd suggest Apache Xerces as the
parser/serializer package if you're working in C or Java, but since SAX
is pretty well standardized you can fairly easily experiment with
different parsers if you want to spend the time on that.)
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Feb 22 '07 #4
Good point, Pavel. Only 80MB? Unless the querant has a massively
inadequate or overloaded machine (which is possible), that really
shouldn't be a problem; by today's bloated standards that's a smallish
file. We're missing some information.

My suggestion of switching to SAX-based might still make sense, but I
think it's appropriate to spend more time figuring out where the
bottleneck is in what was actually attempted.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Feb 22 '07 #5
On Feb 22, 3:40 pm, Joe Kesselman
<keshlam-nos...@comcast. netwrote:
Only 80MB? Unless the querant has a massively inadequate
or overloaded machine (which is possible), that really
shouldn't be a problem
Well, I was running the test on one of our data-crunchers,
which is *both* inadequate and overloaded. Still wasn't a
problem.
My suggestion of switching to SAX-based might still make
sense
It always does when the problem seems well-suited for
streaming solutions, doesn't it? Granted, typical XSLT
processors are not at all bad at that kind of stuff either,
but coding it in C using a fast SAX-parser is probably
going to result in an order of magnitude increase in
performance. Which might be just what was needed for smooth
operation.

--
Pavel Lepin

Feb 22 '07 #6
In article <af************ *************** ***@comcast.com >,
Joe Kesselman <ke************ @comcast.netwro te:
>Good point, Pavel. Only 80MB?
80MB is not huge, but there's a big difference between 80MB of
lightly-marked-up text, and 80MB of <a>24</a><a>23.4</a><a>... In the
latter case, it could easily expand greatly when parsed.

-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Feb 22 '07 #7
Richard Tobin wrote:
80MB is not huge, but there's a big difference between 80MB of
lightly-marked-up text, and 80MB of <a>24</a><a>23.4</a><a>... In the
latter case, it could easily expand greatly when parsed.
Depends on what the underlying data model is -- which is why we invented
DTM for the Xalan processor; making every node a Java object would
indeed have been hugely wasteful of memory.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Feb 22 '07 #8
On Feb 22, 6:18 pm, Joseph Kesselman <keshlam-nos...@comcast. net>
wrote:
Richard Tobin wrote:
80MB is not huge, but there's a big difference between 80MB of
lightly-marked-up text, and 80MB of <a>24</a><a>23.4</a><a>... In the
latter case, it could easily expand greatly when parsed.

Depends on what the underlying data model is -- which is why we invented
DTM for the Xalan processor; making every node a Java object would
indeed have been hugely wasteful of memory.
Hi, sorry for the late reply!
Richard, thats exactly the problem!

I have 80MB of a XML with the following structure:
Expand|Select|Wrap|Line Numbers
  1. ....
  2. <suppliers>
  3. <item>
  4. <ID>21</ID>
  5. <N>Super Duper Computer store</N>
  6. <A>24</A>
  7. <B>18</B>
  8. <Z>1</Z>
  9. </item>
  10. <item>
  11. <ID>21</ID>
  12. <N>Get 1 Pay 2 Computer store</N>
  13. <A>24</A>
  14. <B>18</B>
  15. <Z>2</Z>
  16. </item>
  17. ....
  18. </suppliers>
  19. ....
  20. <articles>
  21. <item>
  22. <ID>3</ID>
  23. <SID>21</SID>
  24. <A>24</A>
  25. <B>18</B>
  26. </item>
  27. <item>
  28. <ID>4</ID>
  29. <SID>22</SID>
  30. <A>24</A>
  31. <B>16</B>
  32. </item>
  33. ....
  34. </articles>
  35. ....
  36.  
I'm (ahem.. was) using MSXML DOM.
The weird thing is that I dont know how to deal with the problem. Here
is what I am supposed to do:
- Find all suppliers (in 90% of cases only one) for an article. To do
this use <SIDin "articles", which sorresponds to <IDin
"suppliers" , but only for those where <Zin "suppliers" have value 2.
(<Aand <Bin "articles" are the prices.)
I didnt invent the XML! Its weird!!

Now I dont know how to deal with the case. I tried SAX and DOM but the
code got ugly so fast, that I gave it up yesterday. XPath sounded like
a good option, but the performance of it is like pfui. ...and by the
way, when using DOM with Java I got rid of the OutOfMemoryExce ption,
when a set JVM max memory to 1024MB.
Any ideas?

Feb 24 '07 #9
starlight wrote:
- Find all suppliers (in 90% of cases only one) for an article. To do
this use <SIDin "articles", which sorresponds to <IDin
"suppliers" , but only for those where <Zin "suppliers" have value 2.
(<Aand <Bin "articles" are the prices.)
The items in your XML data seem to be a simple
list of "records". This kind of data can be
processed efficiently with languages that map
the SAX-approach to their internal control flow.
One example of this kind of XML processing is
described in a small booklet that we wrote for
XMLgawk, the XML extension of GNU Awk. XMLgawk
is known to process large amounts of large files
in a short time. But you wont get a DOM:

http://home.vrweb.de/~juergen.kahrs/...with-XML-paths
way, when using DOM with Java I got rid of the OutOfMemoryExce ption,
when a set JVM max memory to 1024MB.
Any ideas?
Try XMLgawk. 80 MB of the data that you describe should
be processed in less than one minute (assuming the
algorithm is as simple as what you described).
Feb 24 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

49
2534
by: Paul Rubin | last post by:
I've started a few threads before on object persistence in medium to high end server apps. This one is about low end apps, for example, a simple cgi on a personal web site that might get a dozen hits a day. The idea is you just want to keep a few pieces of data around that the cgi can update. Immediately, typical strategies like using a MySQL database become too big a pain. Any kind of compiled and installed 3rd party module (e.g....
3
2186
by: Andy Dingley | last post by:
I've just started on a new project and inherited a huge pile of XSLT (and I use the term "pile" advisedly !) It runs at glacial speed, and I need to fix this this. Platform is MSXML 4 / ASP Any advice on benchmarking tools / techniques ? I have no budget for tool-building, so if there's anything already out there, that would be good to know.
1
1476
by: Diego Rivero | last post by:
Hi. I'm working with the XsltTransform class and I found that invocations to extension objects are extremely time consuming in contrast to invocations to embebed code using "msxsl:script" tag.
2
3656
by: Trevor Oakley | last post by:
I am writing thousands of html pages from an MS SQL source using a DataSet and then an XslTransform. I have an interest in making the code run faster as it takes several minutes (sometimes ten minutes) to generate a batch of pages (say two thousand). If anyone has URL resources which performance information germane to XSL Transforms, Streams, and XML I am interested in hearing about them. I have written some notes below of what I am...
1
4289
by: John A Grandy | last post by:
I've got an app that has hundreds of medium-sized (100s of elements) XML files on disk (not in db). Right now these are loaded via XMLDocument.Load and searched with XPATH. The performance has become unacceptable. Performance improvment strategies I know of: 1. Switching to XMLReader
14
755
by: ajfish | last post by:
Hi, I am trying to allocate a unique ID to every instance of tag 'foo' in a large XML document. currently I'm doing this: <xsl:variable name="UniqueId"> <xsl:number count="foo" level="any"/> </xsl:variable> but with .Net framework 1.1 (using XPathDocument) it is very slow for
3
5447
by: Andy Fish | last post by:
Hi, From reading the documentation, I get the impression that XslCompiledTransform should be faster than XslTransform on my test with a large complex document and a large complex XSLT, the transform took 4 minutes with XslTransform but 7 minutes with XslCompiledTransform. However, with the same stylesheet on another large complex document, the
0
2408
by: SpaceMarine | last post by:
hello, im having a discussion w/ one of my associates, and we're are trying to get a consensus on a possible performance scenario. we're working a/ 3-rd party component that produces PDFs using "XML-FO", a verbose description & layout doc. it can accept either: 1) a complete, verbose XML-FO doc 2) data-only XML, plus an XSLT doc to produce valid verbose XML-FO, which it transforms
4
1430
by: Andy Fish | last post by:
Hi, I am using .Net 2.0 to run an XSLT process. It basically takes a word XML document at it's input, plus a separate XML file opened using the document() function and applies changes to the word document on the basis of the secondary file. A customer has reported that for one document, the process takes about an hour to run (the word doc is 4mb and the file of changes is about 100k)
0
7885
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8031
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6686
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5426
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3923
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2399
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1493
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1231
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.