[
https://issues.apache.org/jira/browse/PDFBOX-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14018590#comment-14018590
]
Petr Slaby commented on PDFBOX-2117:
------------------------------------
Attached is a patch that tackles the problem. There are the following
improvements:
- if the shading is horizontal or vertical, the values can be computed just for
the given direction and simply copied in the other one
- cache at least some of the computed values in a simple lookup table
- cache internal structures in PDFunctionType3 rather than create them again
and again from COSDictionary
- cache at least some of the computed values in PDColorSpaceRGB and
PDColorSpaceCMYK using a simple lookup table. The ICC profiles are very slow
and do a lot of math to convert the values. In my test, PDColorSpaceRGB is
always high on hot spot list, the CMYK version not so much. I am not sure
whether this is because my test documents mostly use RGB or because the CMYK
profile is faster. I assume the first is true.
I have rendered the first page of five different test documents into a bitmap.
The time spent in AxialShadingContext#getRaster() originally was about 24,5
seconds, with the proposed improvements it is about 4 seconds, i.e. five to six
times faster (results might vary with documents and hardware, but the modified
implementation is definitely faster)
> AxialShadingContext is slow
> ---------------------------
>
> Key: PDFBOX-2117
> URL: https://issues.apache.org/jira/browse/PDFBOX-2117
> Project: PDFBox
> Issue Type: Bug
> Reporter: Petr Slaby
> Attachments: AxialShading.patch
>
>
> AxialShadingContext#getRaster() is on top of profiler hot spots in documents
> that use an axial shading. Inside it, the slowest part is calling
> PDColorSpaceRGB#toRGB() and PDFunctionType3#eval() (in this order).
>
--
This message was sent by Atlassian JIRA
(v6.2#6252)