@tsteur opened this Pull Request on November 20th 2017 Owner

This seems to improve the performance of serializing a data table which is useful when archiving. In my case it made the archiving of a monthly archive almost twice as fast from about 120 seconds down to like 70seconds.



getSerialized is called here 385 times and took before 51 seconds, afterwards about 10 seconds. The thing is that getSerialized gets called recursive, and on the 2nd layer, it is called almost 8000 times, and on the third layer (when having 3 nested dataTables) it is called 40.000 times:


When it is called 40.000 times, it doesn't take much time but on the 2nd layer, it spends about 40seconds in the method itself (excluding calling any methods). Looking at the function itself I realized the $aSerializedDataTable + $subTable->getSerialized($maximumRowsInSubDataTable, $maximumRowsInSubDataTable, $columnToSortByBeforeTruncation, $aSerializedDataTable) call which merges BIG arrays over time and seems to be the slow part.

So I changed it to getSerialized($maximumRowsInDataTable = null, $maximumRowsInSubDataTable = null, $maximumRowsInSubDataTable = null, $columnToSortByBeforeTruncation = null) $columnToSortByBeforeTruncation = null, $aSerializedDataTable = array()) which made it like 2 or 3 times slower because it is copying the arrays even more etc.

But when passing as reference it is suddenly fast (less copying):


It is down from 40 seconds to 2 seconds.

This Pull Request was closed on November 20th 2017
Powered by GitHub Issue Mirror