# Making a XML::Parser App Multithreaded

**URL:** <https://www.ruby-forum.com/t/making-a-xml-parser-app-multithreaded/110883>\
**Category:** Ruby\
**Created:** [July 31, 2007, 7:21pm UTC](https://www.ruby-forum.com/t/making-a-xml-parser-app-multithreaded/110883 "2007-07-31T19:21:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nappin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f475e1/32.png) [@nappin](https://www.ruby-forum.com/u/nappin)\
**Post date:** [July 31, 2007, 7:21pm UTC](https://www.ruby-forum.com/t/making-a-xml-parser-app-multithreaded/110883/1 "2007-07-31T19:21:32Z")

</div>

I wrote an application to parse a large xml file (over 20GB) using  
XML::Parser. It runs on a multicore system, however, and takes forever  
since it uses only one core. Maybe this is more of a SAX question, but  
is there anyway to rewrite my app so that it takes advantage of multiple  
cores?

Thanks

---

<div class="post-metadata">

**Author:** ![nappin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f475e1/32.png) [@nappin](https://www.ruby-forum.com/u/nappin)\
**Post date:** [August 2, 2007, 12:06am UTC](https://www.ruby-forum.com/t/making-a-xml-parser-app-multithreaded/110883/2 "2007-08-02T00:06:32Z")

</div>

On 31.07.2007 19:21, Raymond O’Connor wrote:

> I wrote an application to parse a large xml file (over 20GB) using  
> XML::Parser. It runs on a multicore system, however, and takes forever  
> since it uses only one core. Maybe this is more of a SAX question, but  
> is there anyway to rewrite my app so that it takes advantage of multiple  
> cores?

Not the parsing part, because there is no way that you can parallelize  
reading an XML file and stream parsing it in a reasonable way (you would  
have to stuff all parse events into a queue anyway to make sure they are  
processed in the correct order).

For the rest it depends on what you do with parse results. For that we  
would need more detail.

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![nappin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f475e1/32.png) [@nappin](https://www.ruby-forum.com/u/nappin)\
**Post date:** [August 3, 2007, 1:37am UTC](https://www.ruby-forum.com/t/making-a-xml-parser-app-multithreaded/110883/3 "2007-08-03T01:37:26Z")

</div>

Robert K. wrote:

> Not the parsing part, because there is no way that you can parallelize  
> reading an XML file and stream parsing it in a reasonable way (you would  
> have to stuff all parse events into a queue anyway to make sure they are  
> processed in the correct order).
> 
> For the rest it depends on what you do with parse results. For that we  
> would need more detail.
> 
> Kind regards
> 
> robert

It’s pretty much the parsing that I need to speed up, so it looks like  
I’ll have to live with it for now. Thank you very much for the  
response.
