doy/spreadsheet-parsexlsx — pull request #21 by merrilymeredith (2014-03-19 04:24:31+00:00)
Title: Reduce burst memory use while parsing by using twig mode

While working with ParseXLSX and some really insanely large spreadsheets, I had to look into ways to reduce memory use just during parsing, as my perl processes were hitting the 2GB 32-bit process cap. In the end I made a subclass of ParseXLSX that makes some pretty drastic changes to cut memory use, but I thought you may be interested in the more conservative bits of that back in your original module.

This PR continues to pass all tests on my end, and makes the following changes:

- Build Shared Strings into a flat array since we're not doing anything other than text right now
- Use XML::Twig's twig_handlers mode to build that strings array while parsing, without building an entire XML object tree in memory and iterating over it.
- Also use twig_roots to handle the worksheet parsing, avoiding loading up all cells as XML objects while creating the actual Cell objects.

On my machine, these changes reduce the max RSS during the test suite by ~11MB, and don't appear to make an appreciable difference in execution time.