[prev in list] [next in list] [prev in thread] [next in thread]
List: openjdk-2d-dev
Subject: Re: [OpenJDK 2D-Dev] Rendering images from PDF files slower in OpenJDK
From: Laurent_Bourgès <bourges.laurent () gmail ! com>
Date: 2018-10-05 6:45:19
Message-ID: CAKjRUT7ALdjKA5ZvdO8LV3_cGAOTBRtjZu7xQ9zcccPfPdBb8w () mail ! gmail ! com
[Download RAW message or body]
Phil,
Le ven. 5 oct. 2018 à 08:06, Philip Race <philip.race@oracle.com> a écrit :
> Yep .. I vaguely remembered that we had such a report but would also have
> had to hunt to locate it.
>
> So we have the probable reason but not the solution.
>
> FWIW I think it would be a fun project for a LCMS developer ...
>
I looks like a call to let me have a look. Maybe I could inspect what makes
LCMS slow (lerp?) ... and optimize the C code or at least tune gcc options.
I would not make MT in lcms as it can affect MT in java.
Maybe PDFImage could convert tiles instead of the all image ?
Anyway I will publish my lknux perf report showing time spent in kcms /
lcms asap.
PS: I tested OpenJDK8 and perf is on par with OpenJDK9.
Laurent
> On 10/4/18, 10:47 PM, Daniel Persson wrote:
>
> Hi Phil.
>
> Well it seems like you've been in this discussion before
>
> https://bugs.openjdk.java.net/browse/JDK-8041125
>
> Wasn't aware that PDFBox PDF2Image used the Kcms Provider per default.
> You may close this issue as we have figured out the reason.
>
> Best regards
> Daniel
>
> On Fri, Oct 5, 2018 at 7:27 AM Philip Race <philip.race@oracle.com> wrote:
>
> >
> >
> > On 10/4/18, 10:22 PM, Daniel Persson wrote:
> >
> > Hi Laurent
> >
> > Well that seems like a reasonable assumption.
> >
> > https://github.com/kalaspuffar/ColorConvTest/blob/master/KCMSTest.md
> >
> > The test with a "blank" image has a 1 seconds difference.
> >
> > And the test with an image from the PDF in question have a 52 seconds
> > difference.
> >
> >
> > I tried playing with different image data but I didn't see a sensitivity
> > to that.
> > Maybe I needed to try something more complex.
> >
> >
> > So why don't OpenJDK 9 and forward have KcmsServiceProvider bundled?
> > Does this provider make a worse result on the image?
> >
> > It is not open source. It cannot be part of OpenJDK. Ever.
> > And see my other email for the other reasons.
> > So there is no quick or easy solution.
> >
> > FWIW the #1 reason I left KCMS in Oracle 8 and even 9 was because of the
> > MT performance
> > issue, but as we now converge Oracle JDK & OpenJDK that was a non-starter
> > and it was
> > removed along with other closed source components.
> >
> > -phil.
> >
> > Best regards
> > Daniel
> >
> >
> >
> >
> > On Fri, Oct 5, 2018 at 6:55 AM Laurent Bourgès <bourges.laurent@gmail.com>
> > wrote:
> >
> > > Phil,
> > > I just gg a bit and got the PDFImage source:
> > >
> > > public static void main( String[] args ) throws IOException
> > > 79 {
> > > 80 try
> > > 81 {
> > > 82 // force KCMS (faster than LCMS) if available
> > > 83 Class.forName("sun.java2d.cmm.kcms.KcmsServiceProvider");
> > > 84 System.setProperty("sun.java2d.cmm",
> > > "sun.java2d.cmm.kcms.KcmsServiceProvider");
> > > 85 }
> > > 86 catch (ClassNotFoundException e)
> > > 87 {
> > > 88 LOG.debug("KCMS service not found - using LCMS", e);
> > > 89 }
> > > 90
> > >
> > >
> > > https://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java?revision=1829374&view=markup
> > >
> > > That's all folks !
> > >
> > > Le ven. 5 oct. 2018 Ã 01:00, Philip Race <philip.race@oracle.com> a
> > > écrit :
> > >
> > > > Yep. LCMS is the default in 8u.
> > > >
> > > > And although KCMS is a lot faster on my CConv test ...
> > > >
> > > > ~/jdk8u181/bin/java CConv
> > > > 13289
> > > >
> > > > ~/jdk8u181/bin/java
> > > > -Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider CConv
> > > > 5131
> > > >
> > > >
> > > > It makes no difference on the pdf conversion :
> > > >
> > > > ~/jdk8u181/bin/java -jar pdfbox-app-2.0.11.jar PDFToImage -time
> > > > test.pdf Rendered 1 page in 4985ms
> > > >
> > > > ~/jdk8u181/bin/java
> > > > -Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider -jar
> > > > pdfbox-app-2.0.11.jar PDFToImage -time test.pdf
> > > > Rendered 1 page in 4723ms
> > > >
> > > >
> > > > Note: KCMS maybe faster on CConv but it has no support for modern ICC
> > > > profiles
> > > > and I haven't checked if it is even applying the pdfbox one properly.
> > > > But it does have support to split a job into concurrent tasks for
> > > > sub-images
> > > > which can help on the larger images like the one I am using in CConv.
> > > >
> > > > -phil.
> > > >
> > > > On 10/4/18, 2:24 PM, Philip Race wrote:
> > > >
> > > > I might be losing it, but I am 99% sure that LCMS is the color
> > > > conversion engine in 8.
> > > > KCMS was there only for backup. You'd have to know the magic flag to
> > > > get it and
> > > > no one has said anything to the effect that they are using it.
> > > >
> > > > -phil.
> > > >
> > > > On 10/4/18, 11:33 AM, Laurent Bourgès wrote:
> > > >
> > > > Phil,
> > > > I wondered if ang RenderingHint defaults changed since 8...
> > > >
> > > > Moreover I started playing with linux perf + jit agent and it is easy
> > > > than before wigh oprofile + jvmtiagent.
> > > >
> > > > I noticed that OracleJDK8 uses KCMS and OpenJDK11 uses LCMS for color
> > > > conversion as does OpenJDK8, that could explain the performance gap.
> > > >
> > > > Finally PDFImage test is run only once so the overhead may come from
> > > > warmup (jit, g1)...
> > > >
> > > > More later,
> > > > Laurent
> > > >
> > > > Le jeu. 4 oct. 2018 Ã 20:03, Phil Race <philip.race@oracle.com> a
> > > > écrit :
> > > >
> > > > >
> > > > >
> > > > > On 10/03/2018 11:58 PM, Laurent Bourgès wrote:
> > > > >
> > > > > Hi,
> > > > > I will get the code and add debugging logs: env & system properties
> > > > > and java2d RenderingHints.
> > > > >
> > > > >
> > > > > The code in pdfbox passes null for the hints. So there should be no
> > > > > difference attributable to that.
> > > > >
> > > > > -phil.
> > > > >
> > > > >
> > > > > I suspect these hints are different or have a noticiable impact: color
> > > > > interpolation & rendering quality.
> > > > >
> > > > > I suppose the backend corresponds to software loops but some 2d
> > > > > operations can be accelerated ?
> > > > >
> > > > > Anyway I will push any change in the code.
> > > > >
> > > > > PS: I can run linux perf to profile both java & native code....
> > > > >
> > > > > Cheers,
> > > > > Laurent
> > > > >
> > > > > Le jeu. 4 oct. 2018 Ã 07:50, Daniel Persson <mailto.woden@gmail.com>
> > > > > a écrit :
> > > > >
> > > > > > Hi Philip and Laurent.
> > > > > >
> > > > > > I've talked with Tilman and Andreas from the PDFBox team and they see
> > > > > > similar connections to the ColorConvertOp filter but wanted to try with \
> > > > > > one of the images of the PDF as a raster.
> > > > > >
> > > > > > As we try different things I thought it good for collaboration to
> > > > > > create a repository with the code so all can contribute.
> > > > > >
> > > > > > https://github.com/kalaspuffar/ColorConvTest
> > > > > >
> > > > > > I've run the 3 different tests on my Machine (Thinkpad P51s) with
> > > > > > custom Gentoo installed, if important to the conversation.
> > > > > >
> > > > > > I tried to invite you all as collaborators to this repository if you
> > > > > > think this is a bad Idea let me know.
> > > > > >
> > > > > > Best regards
> > > > > > Daniel
> > > > > >
> > > > > > On Wed, Oct 3, 2018 at 7:51 PM Laurent Bourgès <
> > > > > > bourges.laurent@gmail.com> wrote:
> > > > > >
> > > > > > > Very good job, phil.
> > > > > > >
> > > > > > > I will try your CCONV test on my linux machine to see if it is
> > > > > > > platform dependent ... or hw ?
> > > > > > >
> > > > > > > Laurent
> > > > > > >
> > > > > > > Le mer. 3 oct. 2018 Ã 19:19, Philip Race <philip.race@oracle.com> a
> > > > > > > écrit :
> > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > On 10/3/18, 1:15 AM, Laurent Bourgès wrote:
> > > > > > > >
> > > > > > > > Phil,
> > > > > > > >
> > > > > > > > If you look at the given pdf file, it has large images that exceed
> > > > > > > > 2k so such ones may be more costly to convert.
> > > > > > > >
> > > > > > > >
> > > > > > > > FWIW the one I profiled was by far the largest at 2577x1540.
> > > > > > > > The rest are more like 100x100, 200x200 or 500x500 - all
> > > > > > > > approximations.
> > > > > > > >
> > > > > > > >
> > > > > > > > As jpeg decoder in openjdk11 is different than oraclejdk8, it may
> > > > > > > > cause more ColorConvertOp filter operations ... if color profiles are
> > > > > > > > different.
> > > > > > > >
> > > > > > > >
> > > > > > > > That doesn't seem likely and in fact since I instrumented
> > > > > > > > ColorConvertOp in 8 & 11, I know exactly how many times it was \
> > > > > > > > invoked by pdfbox, (11 times in both cases) and that all the image \
> > > > > > > > data is the same. SRC and DEST are the same types etc.
> > > > > > > >
> > > > > > > > Also the version of LCMS is the same in 8 and 11 (v2.9).
> > > > > > > >
> > > > > > > > -phil
> > > > > > > >
> > > > > > > >
> > > > > > > > Anyway this performance is not related to Marlin renderer, so I can
> > > > > > > > not help much except in its diagnostic.
> > > > > > > >
> > > > > > > > Cheers,
> > > > > > > > Laurent
> > > > > > > >
> > > > > > > > Le mar. 2 oct. 2018 Ã 23:35, Philip Race <philip.race@oracle.com>
> > > > > > > > a écrit :
> > > > > > > >
> > > > > > > > > I've spent some time examining what pdfbox is passing to
> > > > > > > > > ColorConvertOp
> > > > > > > > > It is called about 10 or 11 times in this test with images
> > > > > > > > > typically 1-2K in each dimension.
> > > > > > > > > The input image is a Custom BufferedImage which uses an
> > > > > > > > > ICC_ColorSpace constructed
> > > > > > > > > from a color profile file that is embedded in pdfbox which is an
> > > > > > > > > open source equivalent
> > > > > > > > > of what Acrobat uses. It has a 4 component raster and is opaque
> > > > > > > > >
> > > > > > > > > This is filtered into a 3 component standard INT_RGB ColorModel.
> > > > > > > > >
> > > > > > > > > I've distilled this down into a small program which has an copy of
> > > > > > > > > the method
> > > > > > > > > that is defined in pdfbox and is invoking the supposedly slow
> > > > > > > > > ColorConvertOp.
> > > > > > > > >
> > > > > > > > > So I believe this is all exactly what is happening in pdfbox.
> > > > > > > > >
> > > > > > > > > What I find is that it is actually much faster on JDK11 than JDK 8.
> > > > > > > > >
> > > > > > > > > prrubuntu:~$ ~/jdk-11/bin/java CConv
> > > > > > > > > 4881
> > > > > > > > > prrubuntu:~$ ~/jdk8u181/bin/java CConv
> > > > > > > > > 12529
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > I can't say why that would be but the results are clear.
> > > > > > > > > So I am left to suppose that pdfbox really is doing something
> > > > > > > > > different in 8 vs 11.
> > > > > > > > > Or that this not the real problem. What do others see ?
> > > > > > > > >
> > > > > > > > > I've attached the program. The 1Mb color profile file can be got
> > > > > > > > > from the pdfbox sources.
> > > > > > > > >
> > > > > > > > > -phil.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On 10/2/18, 9:35 AM, Laurent Bourgès wrote:
> > > > > > > > >
> > > > > > > > > Hi Daniel,
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Let's not compare apples and oranges. What I can see it takes the
> > > > > > > > > > same route and behave similarly.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > I agree, I did not take enough time to get accurate profiles,
> > > > > > > > > sorry.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > > If you look at
> > > > > > > > > > http://uhash.com/java_reg/Call_Tree_java_8.html
> > > > > > > > > > http://uhash.com/java_reg/Call_Tree_java_11.html
> > > > > > > > > >
> > > > > > > > > > You can see that ConvertOp.filter takes 1.5s longer on Java 11.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > I confirm: 1.8s vs 300ms.
> > > > > > > > >
> > > > > > > > > Philip, do you know what could have change in this 2d area ?
> > > > > > > > >
> > > > > > > > > I imagine ColorConvertOp delegates to native code so color profile
> > > > > > > > > (ICC) or hidpi support may have an impact here (or just compiler \
> > > > > > > > > options may be different) ...
> > > > > > > > >
> > > > > > > > > If needed, I could profile native code using oprofile / perf.
> > > > > > > > >
> > > > > > > > > Laurent
> > > > > > > > >
> > > > > > > > >
> > > > >
[Attachment #3 (text/html)]
<div dir="auto"><div>Phil,<br><br><div class="gmail_quote"><div dir="ltr">Le ven. 5 \
oct. 2018 Ã 08:06, Philip Race <<a \
href="mailto:philip.race@oracle.com">philip.race@oracle.com</a>> a écrit \
:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Yep .. I vaguely remembered that we had such a report but would also
have<br>
had to hunt to locate it.<br>
<br>
So we have the probable reason but not the solution.<br>
<br>
FWIW I think it would be a fun project for a LCMS developer ... \
<br></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">I looks \
like a call to let me have a look. Maybe I could inspect what makes LCMS slow (lerp?) \
... and optimize the C code or at least tune gcc options. </div><div dir="auto">I \
would not make MT in lcms as it can affect MT in java.</div><div dir="auto">Maybe \
PDFImage could convert tiles instead of the all image ?</div><div \
dir="auto"><br></div><div dir="auto">Anyway I will publish my lknux perf report \
showing time spent in kcms / lcms asap.</div><div dir="auto"><br></div><div \
dir="auto">PS: I tested OpenJDK8 and perf is on par with OpenJDK9.</div><div \
dir="auto"><br></div><div dir="auto">Laurent</div><div dir="auto"><br></div><div \
dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><br> On 10/4/18, 10:47 \
PM, Daniel Persson wrote: <blockquote type="cite">
<div dir="ltr">
<div dir="ltr">Hi Phil.
<div><br>
</div>
<div>Well it seems like you've been in this discussion before</div>
<div><br>
</div>
<div><a href="https://bugs.openjdk.java.net/browse/JDK-8041125" \
target="_blank" rel="noreferrer">https://bugs.openjdk.java.net/browse/JDK-8041125</a><br>
</div>
<div><br>
</div>
<div>Wasn't aware that PDFBox PDF2Image used the Kcms Provider
per default.</div>
<div>You may close this issue as we have figured out the
reason.</div>
<div><br>
</div>
<div>Best regards</div>
<div>Daniel</div>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Fri, Oct 5, 2018 at 7:27 AM Philip Race <<a \
href="mailto:philip.race@oracle.com" target="_blank" \
rel="noreferrer">philip.race@oracle.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> <div bgcolor="#FFFFFF" text="#000000"> <br>
<br>
On 10/4/18, 10:22 PM, Daniel Persson wrote:
<blockquote type="cite">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div>Hi Laurent</div>
<div><br>
</div>
Well that seems like a reasonable assumption.
<div><br>
</div>
<div><a \
href="https://github.com/kalaspuffar/ColorConvTest/blob/master/KCMSTest.md" \
target="_blank" rel="noreferrer">https://github.com/kalaspuffar/ColorConvTest/blob/master/KCMSTest.md</a><br>
</div>
<div><br>
</div>
<div>The test with a "blank" image has a 1 seconds
difference.</div>
<div><br>
</div>
<div>And the test with an image from the PDF in
question have a 52 seconds difference.</div>
</div>
</div>
</div>
</blockquote>
<br>
I tried playing with different image data but I didn't see a
sensitivity to that.<br>
Maybe I needed to try something more complex.<br>
<blockquote type="cite">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div><br>
</div>
<div>So why don't OpenJDK 9 and forward have
KcmsServiceProvider bundled?</div>
<div>Does this provider make a worse result on the
image?</div>
<div><br>
</div>
</div>
</div>
</div>
</blockquote>
It is not open source. It cannot be part of OpenJDK. Ever. <br>
And see my other email for the other reasons.<br>
So there is no quick or easy solution. <br>
<br>
FWIW the #1 reason I left KCMS in Oracle 8 and even 9 was
because of the MT performance<br>
issue, but as we now converge Oracle JDK & OpenJDK that
was a non-starter and it was<br>
removed along with other closed source components.<br>
<br>
-phil.<br>
<br>
<blockquote type="cite">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div>Best regards</div>
<div>Daniel</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Fri, Oct 5, 2018 at 6:55 AM Laurent
Bourgès <<a href="mailto:bourges.laurent@gmail.com" \
target="_blank" rel="noreferrer">bourges.laurent@gmail.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"> <div dir="auto">Phil,
<div dir="auto">I just gg a bit and got the PDFImage
source:</div>
<div dir="auto"><br>
</div>
<div dir="auto">
<div dir="auto">public static void main( String[]
args ) throws IOException</div>
<div dir="auto">79 <span style="white-space:pre-wrap"> </span> \
{</div>
<div dir="auto">80 <span style="white-space:pre-wrap"> </span> \
try</div>
<div dir="auto">81 <span style="white-space:pre-wrap"> </span> \
{</div>
<div dir="auto">82 <span style="white-space:pre-wrap"> </span> \
// force KCMS (faster than LCMS) if
available</div>
<div dir="auto">83 <span style="white-space:pre-wrap"> </span> \
\
Class.forName("sun.java2d.cmm.kcms.KcmsServiceProvider");</div>
<div dir="auto">84 <span style="white-space:pre-wrap"> </span> \
System.setProperty("sun.java2d.cmm",
"sun.java2d.cmm.kcms.KcmsServiceProvider");</div>
<div dir="auto">85 <span style="white-space:pre-wrap"> </span> \
}</div>
<div dir="auto">86 <span style="white-space:pre-wrap"> </span> \
catch (ClassNotFoundException e)</div>
<div dir="auto">87 <span style="white-space:pre-wrap"> </span> \
{</div>
<div dir="auto">88 <span style="white-space:pre-wrap"> </span> \
LOG.debug("KCMS service not found - using
LCMS", e);</div>
<div dir="auto">89 <span style="white-space:pre-wrap"> </span> \
}</div>
<div dir="auto">90 <span style="white-space:pre-wrap"> \
</span></div> </div>
<div dir="auto"><br>
</div>
<div dir="auto"><a \
href="https://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java?revision=1829374&view=markup" \
rel="noreferrer noreferrer" \
target="_blank">https://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java?revision=1829374&view=markup</a><br>
</div>
<div dir="auto"><br>
</div>
<div dir="auto">That's all folks !</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">Le ven. 5 oct. 2018 Ã 01:00, Philip
Race <<a href="mailto:philip.race@oracle.com" \
rel="noreferrer noreferrer" target="_blank">philip.race@oracle.com</a>> a écrit \
:<br> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"> <div bgcolor="#FFFFFF" \
text="#000000"> Yep. LCMS is the default in 8u.<br>
<br>
And although KCMS is a lot faster on my CConv
test ...<br>
<br>
~/jdk8u181/bin/java CConv<br>
13289<br>
<br>
~/jdk8u181/bin/java
-Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider
CConv<br>
5131<br>
<br>
<br>
It makes no difference on the pdf conversion :<br>
<br>
~/jdk8u181/bin/java -jar pdfbox-app-2.0.11.jar
PDFToImage -time test.pdf Rendered 1 page in
4985ms<br>
<br>
~/jdk8u181/bin/java
-Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider
-jar pdfbox-app-2.0.11.jar PDFToImage -time
test.pdf <br>
Rendered 1 page in 4723ms<br>
<br>
<br>
Note: KCMS maybe faster on CConv but it has no
support for modern ICC profiles<br>
and I haven't checked if it is even applying the
pdfbox one properly.<br>
But it does have support to split a job into
concurrent tasks for sub-images<br>
which can help on the larger images like the one
I am using in CConv.<br>
<br>
-phil.<br>
<br>
On 10/4/18, 2:24 PM, Philip Race wrote:
<blockquote type="cite"> I might be losing it,
but I am 99% sure that LCMS is the color
conversion engine in 8.<br>
KCMS was there only for backup. You'd have to
know the magic flag to get it and<br>
no one has said anything to the effect that
they are using it.<br>
<br>
-phil.<br>
<br>
On 10/4/18, 11:33 AM, Laurent Bourgès wrote:
<blockquote type="cite">
<div dir="auto">Phil,
<div dir="auto">I wondered if ang
RenderingHint defaults changed since
8...</div>
<div dir="auto"><br>
</div>
<div dir="auto">Moreover I started playing
with linux perf + jit agent and it is
easy than before wigh oprofile +
jvmtiagent.</div>
<div dir="auto"><br>
</div>
<div dir="auto">I noticed that OracleJDK8
uses KCMS and OpenJDK11 uses LCMS for
color conversion as does OpenJDK8, that
could explain the performance gap.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Finally PDFImage test is
run only once so the overhead may come
from warmup (jit, g1)...</div>
<div dir="auto"><br>
</div>
<div dir="auto">More later,</div>
<div dir="auto">Laurent</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">Le jeu. 4 oct. 2018 Ã
20:03, Phil Race <<a \
href="mailto:philip.race@oracle.com" rel="noreferrer noreferrer noreferrer" \
target="_blank">philip.race@oracle.com</a>>
a écrit :<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF"> <br>
<br>
<div \
class="m_-7849677760079450493m_-4857852983856186502m_1536195261482230964m_-1809761035282817744m_-4382802829285680414m_8353807606653352915moz-cite-prefix">On
10/03/2018 11:58 PM, Laurent Bourgès
wrote:<br>
</div>
<blockquote type="cite">
<div dir="auto">Hi,
<div dir="auto">I will get the
code and add debugging logs: env
& system properties and
java2d RenderingHints.</div>
</div>
</blockquote>
<br>
The code in pdfbox passes null for the
hints. So there should be no
difference attributable to that.<br>
<br>
-phil.<br>
<blockquote type="cite">
<div dir="auto">
<div dir="auto"><br>
</div>
<div dir="auto">I suspect these
hints are different or have a
noticiable impact: color
interpolation & rendering
quality.</div>
<div dir="auto"><br>
</div>
<div dir="auto">I suppose the
backend corresponds to software
loops but some 2d operations can
be accelerated ?</div>
<div dir="auto"><br>
</div>
<div dir="auto">Anyway I will push
any change in the code.</div>
<div dir="auto"><br>
</div>
<div dir="auto">PS: I can run
linux perf to profile both java
& native code....</div>
<div dir="auto"><br>
</div>
<div dir="auto">Cheers,</div>
<div dir="auto">Laurent</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">Le jeu. 4 oct. 2018
à 07:50, Daniel Persson <<a \
href="mailto:mailto.woden@gmail.com" rel="noreferrer noreferrer
noreferrer noreferrer" \
target="_blank">mailto.woden@gmail.com</a>>
a écrit :<br>
</div>
<blockquote class="gmail_quote" style="margin:0 \
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <div dir="ltr">
<div dir="ltr">Hi Philip and
Laurent.
<div><br>
</div>
<div>I've talked with Tilman
and Andreas from the
PDFBox team and they see
similar connections to the
ColorConvertOp filter but
wanted to try with one of
the images of the PDF as a
raster.</div>
<div><br>
</div>
<div>As we try different
things I thought it good
for collaboration to
create a repository with
the code so all can
contribute.</div>
<div><br>
</div>
<div><a \
href="https://github.com/kalaspuffar/ColorConvTest" rel="noreferrer noreferrer \
noreferrer
noreferrer noreferrer" \
target="_blank">https://github.com/kalaspuffar/ColorConvTest</a><br> </div>
<div><br>
</div>
<div>I've run the 3
different tests on my
Machine (Thinkpad P51s)
with custom Gentoo
installed, if important to
the conversation.</div>
<div><br>
</div>
<div>I tried to invite you
all as collaborators to
this repository if you
think this is a bad Idea
let me know.</div>
<div><br>
</div>
<div>Best regards</div>
<div>Daniel</div>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Wed, Oct 3,
2018 at 7:51 PM Laurent
Bourgès <<a \
href="mailto:bourges.laurent@gmail.com" rel="noreferrer noreferrer
noreferrer noreferrer noreferrer" \
target="_blank">bourges.laurent@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <div \
dir="auto">Very good job, phil.
<div dir="auto"><br>
</div>
<div dir="auto">I will try
your CCONV test on my
linux machine to see if
it is platform dependent
... or hw ?</div>
<div dir="auto"><br>
</div>
<div dir="auto">Laurent</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">Le mer. 3
oct. 2018 Ã 19:19,
Philip Race <<a \
href="mailto:philip.race@oracle.com" rel="noreferrer noreferrer
noreferrer noreferrer noreferrer" \
target="_blank">philip.race@oracle.com</a>>
a écrit :<br>
</div>
<blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">
<div text="#000000" \
bgcolor="#FFFFFF"> <br> <br>
On 10/3/18, 1:15 AM,
Laurent Bourgès wrote:
<blockquote type="cite">
<div dir="auto">Phil,
<div dir="auto"><br>
<div dir="auto">If
you look at
the given pdf
file, it has
large images
that exceed 2k
so such ones
may be more
costly to
convert.</div>
</div>
</div>
</blockquote>
<br>
FWIW the one I
profiled was by far
the largest at
2577x1540.<br>
The rest are more like
100x100, 200x200 or
500x500 - all
approximations.<br>
<blockquote type="cite">
<div dir="auto">
<div dir="auto">
<div dir="auto"><br>
</div>
<div dir="auto">As
jpeg decoder
in openjdk11
is different
than
oraclejdk8, it
may cause more
ColorConvertOp
filter
operations ...
if color
profiles are
different.</div>
</div>
</div>
</blockquote>
<br>
That doesn't seem
likely and in fact
since I instrumented
ColorConvertOp in 8
& 11, I know
exactly how many times
it was invoked<br>
by pdfbox, (11 times
in both cases) and
that all the image
data is the same. SRC
and DEST are the same
types etc.<br>
<br>
Also the version of
LCMS is the same in 8
and 11 (v2.9).<br>
<br>
-phil<br>
<blockquote type="cite">
<div dir="auto">
<div dir="auto">
<div dir="auto"><br>
</div>
<div dir="auto">Anyway
this
performance is
not related to
Marlin
renderer, so I
can not help
much except in
its
diagnostic.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Cheers,</div>
<div dir="auto">Laurent</div>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">Le
mar. 2 oct. 2018
à 23:35, Philip
Race <<a \
href="mailto:philip.race@oracle.com" rel="noreferrer noreferrer noreferrer
noreferrer
noreferrer noreferrer" \
target="_blank">philip.race@oracle.com</a>>
a écrit :<br>
</div>
<blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">
<div text="#000000" \
bgcolor="#FFFFFF"> I've spent some time examining what pdfbox is passing to
ColorConvertOp<br>
It is called
about 10 or 11
times in this
test with
images
typically 1-2K
in each
dimension.<br>
The input
image is a
Custom
BufferedImage
which uses an
ICC_ColorSpace
constructed<br>
from a color
profile file
that is
embedded in
pdfbox which
is an open
source
equivalent<br>
of what
Acrobat uses.
It has a 4
component
raster and is
opaque<br>
<br>
This is
filtered into
a 3 component
standard
INT_RGB
ColorModel.<br>
<br>
I've distilled
this down into
a small
program which
has an copy of
the method<br>
that is
defined in
pdfbox and is
invoking the
supposedly
slow
ColorConvertOp.<br>
<br>
So I believe
this is all
exactly what
is happening
in pdfbox.<br>
<br>
What I find is
that it is
actually much
faster on
JDK11 than JDK
8.<br>
<br>
prrubuntu:~$
~/jdk-11/bin/java
CConv <br>
4881<br>
prrubuntu:~$
~/jdk8u181/bin/java
CConv<br>
12529<br>
<br>
<br>
I can't say
why that would
be but the
results are
clear.<br>
So I am left
to suppose
that pdfbox
really is
doing
something
different in 8
vs 11.<br>
Or that this
not the real
problem. What
do others see
?<br>
<br>
I've attached
the program.
The 1Mb color
profile file
can be got
from the
pdfbox
sources.<br>
<br>
-phil.<br>
<br>
<br>
On 10/2/18,
9:35 AM,
Laurent
Bourgès wrote:
<blockquote type="cite">
<div dir="auto">
<div>Hi
Daniel,</div>
<div dir="auto">
<div class="gmail_quote">
<blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> <div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div><br>
</div>
<div>Let's not
compare apples
and oranges.
What I can see
it takes the
same route and
behave similarly.</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
<div dir="auto"><br>
</div>
<div dir="auto"> I
agree, I did
not take
enough time to
get accurate
profiles,
sorry.<br>
</div>
<div dir="auto"><br>
</div>
<div dir="auto">
<div class="gmail_quote">
<blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> <div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div><br>
</div>
<div>If you
look at</div>
<div><a \
href="http://uhash.com/java_reg/Call_Tree_java_8.html" rel="noreferrer noreferrer
noreferrer
noreferrer
noreferrer
noreferrer
noreferrer noreferrer" \
target="_blank">http://uhash.com/java_reg/Call_Tree_java_8.html</a><br> </div>
<div><a \
href="http://uhash.com/java_reg/Call_Tree_java_11.html" rel="noreferrer noreferrer
noreferrer
noreferrer
noreferrer
noreferrer
noreferrer noreferrer" \
target="_blank">http://uhash.com/java_reg/Call_Tree_java_11.html</a><br> </div>
<div><br>
</div>
<div>You can
see that
ConvertOp.filter
takes 1.5s
longer on Java
11.</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
<div dir="auto"><br>
</div>
<div dir="auto">I
confirm: 1.8s
vs 300ms.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Philip,
do you know
what could
have change in
this 2d area ?</div>
<div dir="auto"><br>
</div>
<div dir="auto">I
imagine
ColorConvertOp
delegates to
native code so
color profile
(ICC) or hidpi
support may
have an impact
here (or just
compiler
options may be
different) ...</div>
<div dir="auto"><br>
</div>
<div dir="auto">If
needed, I
could profile
native code
using oprofile
/ perf.</div>
<div dir="auto"><br>
</div>
<div \
dir="auto">Laurent</div> </div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
<br>
</div>
</blockquote>
</div>
</blockquote>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote></div></div></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic