Memory and Speed Improvements #2821
Replies: 1 comment
-
Hello, @MarkBaker! These results are great, but let me put another perspective regarding resource consumption here, which may address criticism related to specific scenarios. TL;DR: scalability. This library is too tied with a high-level mentality, which is natural considering that this is the PHP perspective afterall (no judging here, just trying to racionalize). Translating this into technicality, the expected result is that the library do its job fastest it can, because PHP, in general, runs in servers, and servers have "a good resource pool". What I see as a trend, because of the evolution of the distributed systems, is that this logic is not anymore an absolute truth. Sometimes the trade-off could be between speed and resource use (be a little bit slower, but without consuming a lot of resources). This is specially the case when we think about horizontal scaling (when its better to have lots of low-resource replicas running instead of one high-resource server, making even more sense for web servers that receive lots of requests). Thinking about this scenario, I can understand why memory is a complain. Even thinking about this great improvements shown above, we see that (if I got it right) the memory consumed to produce this spreadsheet (with relative low number of rows, considering Excel limits, for instance) was far superior than the default PHP memory limit (which is 128M). So, considering that distributed environments tends to work using the default resource limits, this spreadsheet couldn't be written in this perspective. To summarize the idea: this is probably the best PHP library to work with spreadsheets, but its design/foundation haven't taken scalability into account and, for this scenarios, it is indeed a understandable complain. It is even something that I'm having trouble with, that forced me to search for alternatives. I really don't know deeper this library (and others) or even the spreadsheet formats particularities to give any technical guidance (and don't even know if it should be my role here). I will just give some suggestions, if I may, pointing towards what could be a good future perspective to have an eye on both scenarios:
Hope you and the project's community don't receive this as a criticism or any kind of judgement (the work done here is really great). This is just a perspective on how we got here (afterall this is a community project that keeps growing for a decade yet, which is impressive and helps a lot of people), and pointing towards some perspective changes because of new studies, techs and stacks. Best regards! |
Beta Was this translation helpful? Give feedback.
-
One of the most frequent criticisms raised against PhpSpreadsheet is the excessive memory required to maintain the "in-memory" model of a spreadsheet, particularly when working with larger volumes of data. While caching cell data is an option, the Cells Collection still maintains a simple map of whether cells exist in the cache or not just to provide a faster response for calls to the Cell Collection.
Over the last two months (since the
1.22.0
release), we've done a lot of work to reduce the memory footprint. Normally this entails a trade-off between memory and execution speed. Changes to the Cell Collection for the1.23.0
release reduced memory usage, but at a cost in speed. Further work since then, both on the Cell Collection and the Writers, has reduced memory usage still further, but also improved execution speed again.The following tables summarise the results of these changes between PhpSpreadsheet versions, and also across different versions of PHP for the different Writers.
Example speed and memory results creating and writing a 32 column by 16384 row spreadsheet:
Creating/Writing an Xlsx Spreadsheet
With PHP 7.4 against different versions of PhpSpreadsheet:
Comparison using the same spreadsheet between releases with different versions of PHP:
Creating/Writing an Xls Spreadsheet
With PHP 7.4 against different versions of PhpSpreadsheet:
Comparison using the same spreadsheet between releases with different versions of PHP:
Creating/Writing an Ods Spreadsheet
With PHP 7.4 against different versions of PhpSpreadsheet:
Comparison using the same spreadsheet between releases with different versions of PHP:
Creating/Writing the same Spreadsheet as Html
With PHP 7.4 against different versions of PhpSpreadsheet:
Comparison using the same spreadsheet between releases with different versions of PHP:
Beta Was this translation helpful? Give feedback.
All reactions