Parsing the RML with zope.interface takes longer than rendering the PDF with ReportLab
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
z3c.rml |
Fix Committed
|
Undecided
|
Unassigned |
Bug Description
I was looking into why some RML documents were significantly slower to render than others and the slowness seems to come from zope.interface and zope.schema.
Generating a ~100 page PDF with a small table on each page takes the following:
Reading the XML and building the flowables: 13.933 seconds
Rendering the flowables with ReportLab: 7.015 seconds
The problem is that a new class is created for every element and every possible attribute of that element.
Some of the big time wasters:
1.491 seconds for 2.1 million calls to zope.interface.
2.125 seconds for 2.3m calls to _interface_
1.647 seconds for 2.1m calls to zope.interface.
A big offender was table cells and once I'd disabled the processStyle method on the TableCell flowable the times dropped to the following:
Reading the XML and building the flowables: 3.128 seconds
Rendering the flowables with ReportLab: 3.104 seconds
I wasn't expecting a change from ReportLab but apparently having no style instead of a copy of the default style is much quicker. I then changed processStyle to only run getAttributes and apply the style if the cell actually has the attribute in the first place.
I wonder if improvements can be made to every element by changing RMLDirective.
Changed in z3c.rml: | |
status: | New → Fix Committed |
Hey Kyle, z3c.rml is now on GitHub, so I would love to get Pull Requests for all of your fixes. this way, we can review and discuss them. Also, if you would like to contribute to z3c.rml, would you consider becoming a ZF committer? Then you could make the changes directly to the code base. My only requirements are that all the tests pass and that we keep test coverage close to 100% or whereever it is now.
https:/ /github. com/zopefoundat ion/z3c. rml