Cache author info in Comment classes #465
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For a spreadsheet with 420 rows and around 150 columns, we were seeing Axlsx serialization times of around 317 seconds. I tracked the problem down to the Axlsx
Comment
andComments
classes always recalculating author lists and indexes of authors. Our workbook had lots of comments and so these recalculations that might otherwise go unnoticed stood out. In a ruby-prof run,Axlsx::Comments#to_xml_string
was taking around 90-95% of the total run time.Since we have no need to indicate comment authors in our workbooks, I initially monkey patched two methods in Axlsx to fix this:
This change took our Axlsx time down to 5 seconds.
This PR achieves the same time savings but preserves the existing capabilities by introducing caching into the sorted
authors
list and into the method that returns the index of an author in that list.