randym / axlsx

xlsx generation with charts, images, automated column width, customizable styles and full schema validation. Axlsx excels at helping you generate beautiful Office Open XML Spreadsheet documents without having to understand the entire ECMA specification. Check out the README for some examples of how easy it is. Best of all, you can validate your xlsx file before serialization so you know for sure that anything generated is going to load on your client's machine.
MIT License
2.62k stars 698 forks source link

High memory consumption on boot #479

Open waiting-for-dev opened 8 years ago

waiting-for-dev commented 8 years ago

Hi,

axlsx uses a big amount of memory on boot. Doing some tests, usually it is second only after rails, but even sometimes axlsx is the first.

Tests have been made in a rails application with derailed_benchmarks.

Here it is a relevant section example running bundle exec derailed bundle:mem:

  axlsx: 17.4492 MiB
    axlsx/workbook/workbook.rb: 5.1563 MiB
      axlsx/workbook/worksheet/worksheet.rb: 0.5156 MiB
    nokogiri: 4.0078 MiB
      nokogiri/xml: 1.8047 MiB
      nokogiri/html: 0.5156 MiB
      nokogiri/nokogiri: 0.4492 MiB
    axlsx/drawing/drawing.rb: 3.0938 MiB
    axlsx/stylesheet/styles.rb: 1.5469 MiB
    htmlentities: 1.2891 MiB
      htmlentities/flavors: 1.0313 MiB
        htmlentities/mappings/expanded: 0.7734 MiB
    axlsx/util/simple_typed_list.rb: 0.5156 MiB

And here it is a link with the result of bundle exec derailed bundle:objects with a Gemfile than only has axlsx on it.

To be honest, I'm not sure I'm going to find the time to inspect it further, but at least I wanted to share what I've done so far.

Thanks.

waiting-for-dev commented 8 years ago

I also have to say that that results were obtained using ruby 2.1. Now we have updated the project to ruby 2.3.1 and the results are much, much better. The average consumption is around 4 MiB. So this issue should only be taken into account if axlxs wants to be optimized for ruby older versions.

waiting-for-dev commented 8 years ago

Well, in another project using ruby 2.3.1 axlsx amounts 11.5 MiB on boot...

sandstrom commented 7 years ago

I had this issue and switched to the xlsxtream gem. It worked really nice for basic csv-like data in xlsx-format!

Fewer features than axlsx, but less memory usage and a simpler code-base.