You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by Daniel Persson <ma...@gmail.com> on 2018/10/03 16:47:44 UTC
Rendering images from PDF files slower in OpenJDK
Hi everyone.
I was doing some preparation to upgrade to OpenJDK 11 and found that image
rendering was slower.
I've talked about it here before but as it is a problem in the jvm I
thought that opening a bug at oracle could be good.
If interested you can follow the issue below:
https://bugs.openjdk.java.net/browse/JDK-8211178
Or following the 2d-dev mailing list at openjdk where we discuss our
findings.
Best regards
Daniel
Re: Rendering images from PDF files slower in OpenJDK
Posted by Tilman Hausherr <TH...@t-online.de>.
Am 05.10.2018 um 07:55 schrieb Daniel Persson:
> If you want to see the difference in run speed I ran the test again
> enabling Kcms and the results are striking.
>
> https://github.com/kalaspuffar/ColorConvTest/blob/master/KCMSTest.md
I ran the PDFBox test on my old PC with 5 iterations:
1.7.0.80: 664
1.8.0.181: 12292
1.9.0.4: 6693
10.0.2: 12172
11: 11952
Btw your project isn't really self-working, because the files aren't in
resources and one of them is missing. I also don't see why you'd need
PDFBox.
I'm a bit surprised too, I had noticed that LCMS was faster. Maybe this
is only for some files, or only on newer PCs.
Tilman
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org
Re: Rendering images from PDF files slower in OpenJDK
Posted by Daniel Persson <ma...@gmail.com>.
Hi again.
Seems as we have figured out what the issue was.
And you have hinted at this before. OpenJDK can't bundle the KCMS (Kodak
Color Management System).
After they switched to using the LittleCMS the color profile used by Adobe
is actually supported and the colors should be more correct.
The old color profile doesn't have support for multi-threaded work on
sub-images so even if it's slower today they will improve it going forward.
I wasn't aware that PDFImage used Kcms by default so I was a bit confused.
Mark Stevens blogged about this 2014 which I have taken most of my
information from.
https://blog.idrsolutions.com/2014/04/color-performance-change-newer-java-releases/
If you want to see the difference in run speed I ran the test again
enabling Kcms and the results are striking.
https://github.com/kalaspuffar/ColorConvTest/blob/master/KCMSTest.md
Best regards
Daniel
On Thu, Oct 4, 2018 at 7:56 AM Daniel Persson <ma...@gmail.com>
wrote:
> Hi Tilman and Andreas
>
> 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 10:31 PM Andreas Lehmkuehler <an...@lehmi.de>
> wrote:
>
>> Am 03.10.2018 um 21:14 schrieb Daniel Persson:
>> > Hi Tilman
>> >
>> > Thank you for looking into this for me, I've run your code with
>> different
>> > java versions and I can see the exact opposite time metrics.
>> >
>> > In my initial test Java 8 was fastest, Java 9 was slowest and 10-11 was
>> > somewhere in the middle.
>> >
>> > Maybe different color profiles are good at different images?
>> > Do you have any more suggestions?
>> Just a guess, but maybe you are comparing apples and oranges? It looks
>> like
>> Daniel is using Linux and AFAIK Tilman is using Windows. That could be
>> the
>> reason for the different results.
>>
>> Andreas
>>
>> > I'll report these findings to Oracle tomorrow.
>> >
>> > Best regards
>> > Daniel
>> >
>> > $ java -jar target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
>> > Raster: ByteInterleavedRaster: width = 2577 height = 1540
>> #numDataElements
>> > 4 dataOff[0] = 0
>> > 60178
>> >
>> > $ /opt/openjdk/jdk-9.0.4/bin/java -jar
>> > target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
>> > Raster: ByteInterleavedRaster: width = 2577 height = 1540
>> #numDataElements
>> > 4 dataOff[0] = 0
>> > 33327
>> >
>> > $ /opt/openjdk/jdk-10.0.2/bin/java -jar
>> > target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
>> > Raster: ByteInterleavedRaster: width = 2577 height = 1540
>> #numDataElements
>> > 4 dataOff[0] = 0
>> > 56596
>> >
>> > $ /opt/openjdk/jdk-11/bin/java -jar
>> > target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
>> > Raster: ByteInterleavedRaster: width = 2577 height = 1540
>> #numDataElements
>> > 4 dataOff[0] = 0
>> > 56988
>> >
>> >
>> > On Wed, Oct 3, 2018 at 8:31 PM Tilman Hausherr <TH...@t-online.de>
>> > wrote:
>> >
>> >> Am 03.10.2018 um 20:08 schrieb Tilman Hausherr:
>> >>>
>> >>> I could expand that one later so that it uses the raster of the actual
>> >>> JPEG image from your PDF.
>> >>
>> >>
>> >> Your JPEG file is here:
>> >>
>> >>
>> >>
>> https://drive.google.com/file/d/1HvXMet6Wygzmko9ZmY9_zlvhv72v_QHf/view?usp=sharing
>> >>
>> >> The modified code - please test on different openjdks. It took 137935
>> on
>> >> oracle jdk8. (you may want to change the "50")
>> >>
>> >>
>> >>
>> >> import java.awt.*;
>> >> import java.awt.color.*;
>> >> import java.awt.image.*;
>> >> import java.io.FileInputStream;
>> >> import javax.imageio.ImageIO;
>> >> import javax.imageio.ImageReadParam;
>> >> import javax.imageio.ImageReader;
>> >> import javax.imageio.stream.ImageInputStream;
>> >> import javax.imageio.stream.MemoryCacheImageInputStream;
>> >>
>> >> public class CConv
>> >> {
>> >>
>> >> static BufferedImage toRGBImageAWT(WritableRaster raster,
>> >> ColorSpace colorSpace)
>> >> {
>> >>
>> >> ColorModel colorModel = new ComponentColorModel(colorSpace,
>> >> false, false, Transparency.OPAQUE,
>> >> raster.getDataBuffer().getDataType());
>> >>
>> >> BufferedImage src = new BufferedImage(colorModel, raster,
>> >> false, null);
>> >> BufferedImage dest = new BufferedImage(raster.getWidth(),
>> >> raster.getHeight(),
>> >> BufferedImage.TYPE_INT_RGB);
>> >> ColorConvertOp op = new ColorConvertOp(null);
>> >> //System.out.println("src="+src);
>> >> //System.out.println("dst="+dest);
>> >> op.filter(src, dest);
>> >> return dest;
>> >> }
>> >>
>> >> public static void main(String args[]) throws Exception
>> >> {
>> >> ImageReader reader =
>> >> ImageIO.getImageReadersByFormatName("JPEG").next();
>> >> WritableRaster raster;
>> >> FileInputStream fis = new FileInputStream("cmyk.jpg");
>> >> try (ImageInputStream iis = new
>> MemoryCacheImageInputStream(fis))
>> >> {
>> >> reader.setInput(iis);
>> >> ImageReadParam irp = reader.getDefaultReadParam();
>> >> raster = (WritableRaster) reader.readRaster(0, irp);
>> >> }
>> >> System.out.println("Raster: " + raster);
>> >>
>> >> ICC_Profile profile =
>> >> ICC_Profile.getInstance("ISOcoated_v2_300_bas.icc");
>> >> ICC_ColorSpace colorSpace = new ICC_ColorSpace(profile);
>> >> long t0 = System.currentTimeMillis();
>> >> for (int i = 0; i < 50; i++)
>> >> {
>> >> toRGBImageAWT(raster, colorSpace);
>> >> }
>> >> long t1 = System.currentTimeMillis();
>> >> System.out.println((t1 - t0));
>> >> }
>> >> }
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
>> >> For additional commands, e-mail: dev-help@pdfbox.apache.org
>> >>
>> >>
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: dev-help@pdfbox.apache.org
>>
>>
Re: Rendering images from PDF files slower in OpenJDK
Posted by Daniel Persson <ma...@gmail.com>.
Hi Tilman and Andreas
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 10:31 PM Andreas Lehmkuehler <an...@lehmi.de>
wrote:
> Am 03.10.2018 um 21:14 schrieb Daniel Persson:
> > Hi Tilman
> >
> > Thank you for looking into this for me, I've run your code with different
> > java versions and I can see the exact opposite time metrics.
> >
> > In my initial test Java 8 was fastest, Java 9 was slowest and 10-11 was
> > somewhere in the middle.
> >
> > Maybe different color profiles are good at different images?
> > Do you have any more suggestions?
> Just a guess, but maybe you are comparing apples and oranges? It looks
> like
> Daniel is using Linux and AFAIK Tilman is using Windows. That could be the
> reason for the different results.
>
> Andreas
>
> > I'll report these findings to Oracle tomorrow.
> >
> > Best regards
> > Daniel
> >
> > $ java -jar target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
> > Raster: ByteInterleavedRaster: width = 2577 height = 1540
> #numDataElements
> > 4 dataOff[0] = 0
> > 60178
> >
> > $ /opt/openjdk/jdk-9.0.4/bin/java -jar
> > target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
> > Raster: ByteInterleavedRaster: width = 2577 height = 1540
> #numDataElements
> > 4 dataOff[0] = 0
> > 33327
> >
> > $ /opt/openjdk/jdk-10.0.2/bin/java -jar
> > target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
> > Raster: ByteInterleavedRaster: width = 2577 height = 1540
> #numDataElements
> > 4 dataOff[0] = 0
> > 56596
> >
> > $ /opt/openjdk/jdk-11/bin/java -jar
> > target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
> > Raster: ByteInterleavedRaster: width = 2577 height = 1540
> #numDataElements
> > 4 dataOff[0] = 0
> > 56988
> >
> >
> > On Wed, Oct 3, 2018 at 8:31 PM Tilman Hausherr <TH...@t-online.de>
> > wrote:
> >
> >> Am 03.10.2018 um 20:08 schrieb Tilman Hausherr:
> >>>
> >>> I could expand that one later so that it uses the raster of the actual
> >>> JPEG image from your PDF.
> >>
> >>
> >> Your JPEG file is here:
> >>
> >>
> >>
> https://drive.google.com/file/d/1HvXMet6Wygzmko9ZmY9_zlvhv72v_QHf/view?usp=sharing
> >>
> >> The modified code - please test on different openjdks. It took 137935 on
> >> oracle jdk8. (you may want to change the "50")
> >>
> >>
> >>
> >> import java.awt.*;
> >> import java.awt.color.*;
> >> import java.awt.image.*;
> >> import java.io.FileInputStream;
> >> import javax.imageio.ImageIO;
> >> import javax.imageio.ImageReadParam;
> >> import javax.imageio.ImageReader;
> >> import javax.imageio.stream.ImageInputStream;
> >> import javax.imageio.stream.MemoryCacheImageInputStream;
> >>
> >> public class CConv
> >> {
> >>
> >> static BufferedImage toRGBImageAWT(WritableRaster raster,
> >> ColorSpace colorSpace)
> >> {
> >>
> >> ColorModel colorModel = new ComponentColorModel(colorSpace,
> >> false, false, Transparency.OPAQUE,
> >> raster.getDataBuffer().getDataType());
> >>
> >> BufferedImage src = new BufferedImage(colorModel, raster,
> >> false, null);
> >> BufferedImage dest = new BufferedImage(raster.getWidth(),
> >> raster.getHeight(),
> >> BufferedImage.TYPE_INT_RGB);
> >> ColorConvertOp op = new ColorConvertOp(null);
> >> //System.out.println("src="+src);
> >> //System.out.println("dst="+dest);
> >> op.filter(src, dest);
> >> return dest;
> >> }
> >>
> >> public static void main(String args[]) throws Exception
> >> {
> >> ImageReader reader =
> >> ImageIO.getImageReadersByFormatName("JPEG").next();
> >> WritableRaster raster;
> >> FileInputStream fis = new FileInputStream("cmyk.jpg");
> >> try (ImageInputStream iis = new
> MemoryCacheImageInputStream(fis))
> >> {
> >> reader.setInput(iis);
> >> ImageReadParam irp = reader.getDefaultReadParam();
> >> raster = (WritableRaster) reader.readRaster(0, irp);
> >> }
> >> System.out.println("Raster: " + raster);
> >>
> >> ICC_Profile profile =
> >> ICC_Profile.getInstance("ISOcoated_v2_300_bas.icc");
> >> ICC_ColorSpace colorSpace = new ICC_ColorSpace(profile);
> >> long t0 = System.currentTimeMillis();
> >> for (int i = 0; i < 50; i++)
> >> {
> >> toRGBImageAWT(raster, colorSpace);
> >> }
> >> long t1 = System.currentTimeMillis();
> >> System.out.println((t1 - t0));
> >> }
> >> }
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
> >> For additional commands, e-mail: dev-help@pdfbox.apache.org
> >>
> >>
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: dev-help@pdfbox.apache.org
>
>
Re: Rendering images from PDF files slower in OpenJDK
Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Am 03.10.2018 um 21:14 schrieb Daniel Persson:
> Hi Tilman
>
> Thank you for looking into this for me, I've run your code with different
> java versions and I can see the exact opposite time metrics.
>
> In my initial test Java 8 was fastest, Java 9 was slowest and 10-11 was
> somewhere in the middle.
>
> Maybe different color profiles are good at different images?
> Do you have any more suggestions?
Just a guess, but maybe you are comparing apples and oranges? It looks like
Daniel is using Linux and AFAIK Tilman is using Windows. That could be the
reason for the different results.
Andreas
> I'll report these findings to Oracle tomorrow.
>
> Best regards
> Daniel
>
> $ java -jar target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
> Raster: ByteInterleavedRaster: width = 2577 height = 1540 #numDataElements
> 4 dataOff[0] = 0
> 60178
>
> $ /opt/openjdk/jdk-9.0.4/bin/java -jar
> target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
> Raster: ByteInterleavedRaster: width = 2577 height = 1540 #numDataElements
> 4 dataOff[0] = 0
> 33327
>
> $ /opt/openjdk/jdk-10.0.2/bin/java -jar
> target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
> Raster: ByteInterleavedRaster: width = 2577 height = 1540 #numDataElements
> 4 dataOff[0] = 0
> 56596
>
> $ /opt/openjdk/jdk-11/bin/java -jar
> target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
> Raster: ByteInterleavedRaster: width = 2577 height = 1540 #numDataElements
> 4 dataOff[0] = 0
> 56988
>
>
> On Wed, Oct 3, 2018 at 8:31 PM Tilman Hausherr <TH...@t-online.de>
> wrote:
>
>> Am 03.10.2018 um 20:08 schrieb Tilman Hausherr:
>>>
>>> I could expand that one later so that it uses the raster of the actual
>>> JPEG image from your PDF.
>>
>>
>> Your JPEG file is here:
>>
>>
>> https://drive.google.com/file/d/1HvXMet6Wygzmko9ZmY9_zlvhv72v_QHf/view?usp=sharing
>>
>> The modified code - please test on different openjdks. It took 137935 on
>> oracle jdk8. (you may want to change the "50")
>>
>>
>>
>> import java.awt.*;
>> import java.awt.color.*;
>> import java.awt.image.*;
>> import java.io.FileInputStream;
>> import javax.imageio.ImageIO;
>> import javax.imageio.ImageReadParam;
>> import javax.imageio.ImageReader;
>> import javax.imageio.stream.ImageInputStream;
>> import javax.imageio.stream.MemoryCacheImageInputStream;
>>
>> public class CConv
>> {
>>
>> static BufferedImage toRGBImageAWT(WritableRaster raster,
>> ColorSpace colorSpace)
>> {
>>
>> ColorModel colorModel = new ComponentColorModel(colorSpace,
>> false, false, Transparency.OPAQUE,
>> raster.getDataBuffer().getDataType());
>>
>> BufferedImage src = new BufferedImage(colorModel, raster,
>> false, null);
>> BufferedImage dest = new BufferedImage(raster.getWidth(),
>> raster.getHeight(),
>> BufferedImage.TYPE_INT_RGB);
>> ColorConvertOp op = new ColorConvertOp(null);
>> //System.out.println("src="+src);
>> //System.out.println("dst="+dest);
>> op.filter(src, dest);
>> return dest;
>> }
>>
>> public static void main(String args[]) throws Exception
>> {
>> ImageReader reader =
>> ImageIO.getImageReadersByFormatName("JPEG").next();
>> WritableRaster raster;
>> FileInputStream fis = new FileInputStream("cmyk.jpg");
>> try (ImageInputStream iis = new MemoryCacheImageInputStream(fis))
>> {
>> reader.setInput(iis);
>> ImageReadParam irp = reader.getDefaultReadParam();
>> raster = (WritableRaster) reader.readRaster(0, irp);
>> }
>> System.out.println("Raster: " + raster);
>>
>> ICC_Profile profile =
>> ICC_Profile.getInstance("ISOcoated_v2_300_bas.icc");
>> ICC_ColorSpace colorSpace = new ICC_ColorSpace(profile);
>> long t0 = System.currentTimeMillis();
>> for (int i = 0; i < 50; i++)
>> {
>> toRGBImageAWT(raster, colorSpace);
>> }
>> long t1 = System.currentTimeMillis();
>> System.out.println((t1 - t0));
>> }
>> }
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: dev-help@pdfbox.apache.org
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org
Re: Rendering images from PDF files slower in OpenJDK
Posted by Tilman Hausherr <TH...@t-online.de>.
Am 03.10.2018 um 21:14 schrieb Daniel Persson:
> Maybe different color profiles are good at different images?
I don't know. You could retry with the official CMYK profile(s) of Adobe.
https://supportdownloads.adobe.com/detail.jsp?ftpID=4075
> Do you have any more suggestions?
No, sorry.
Tilman
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org
Re: Rendering images from PDF files slower in OpenJDK
Posted by Daniel Persson <ma...@gmail.com>.
Hi Tilman
Thank you for looking into this for me, I've run your code with different
java versions and I can see the exact opposite time metrics.
In my initial test Java 8 was fastest, Java 9 was slowest and 10-11 was
somewhere in the middle.
Maybe different color profiles are good at different images?
Do you have any more suggestions?
I'll report these findings to Oracle tomorrow.
Best regards
Daniel
$ java -jar target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
Raster: ByteInterleavedRaster: width = 2577 height = 1540 #numDataElements
4 dataOff[0] = 0
60178
$ /opt/openjdk/jdk-9.0.4/bin/java -jar
target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
Raster: ByteInterleavedRaster: width = 2577 height = 1540 #numDataElements
4 dataOff[0] = 0
33327
$ /opt/openjdk/jdk-10.0.2/bin/java -jar
target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
Raster: ByteInterleavedRaster: width = 2577 height = 1540 #numDataElements
4 dataOff[0] = 0
56596
$ /opt/openjdk/jdk-11/bin/java -jar
target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar
Raster: ByteInterleavedRaster: width = 2577 height = 1540 #numDataElements
4 dataOff[0] = 0
56988
On Wed, Oct 3, 2018 at 8:31 PM Tilman Hausherr <TH...@t-online.de>
wrote:
> Am 03.10.2018 um 20:08 schrieb Tilman Hausherr:
> >
> > I could expand that one later so that it uses the raster of the actual
> > JPEG image from your PDF.
>
>
> Your JPEG file is here:
>
>
> https://drive.google.com/file/d/1HvXMet6Wygzmko9ZmY9_zlvhv72v_QHf/view?usp=sharing
>
> The modified code - please test on different openjdks. It took 137935 on
> oracle jdk8. (you may want to change the "50")
>
>
>
> import java.awt.*;
> import java.awt.color.*;
> import java.awt.image.*;
> import java.io.FileInputStream;
> import javax.imageio.ImageIO;
> import javax.imageio.ImageReadParam;
> import javax.imageio.ImageReader;
> import javax.imageio.stream.ImageInputStream;
> import javax.imageio.stream.MemoryCacheImageInputStream;
>
> public class CConv
> {
>
> static BufferedImage toRGBImageAWT(WritableRaster raster,
> ColorSpace colorSpace)
> {
>
> ColorModel colorModel = new ComponentColorModel(colorSpace,
> false, false, Transparency.OPAQUE,
> raster.getDataBuffer().getDataType());
>
> BufferedImage src = new BufferedImage(colorModel, raster,
> false, null);
> BufferedImage dest = new BufferedImage(raster.getWidth(),
> raster.getHeight(),
> BufferedImage.TYPE_INT_RGB);
> ColorConvertOp op = new ColorConvertOp(null);
> //System.out.println("src="+src);
> //System.out.println("dst="+dest);
> op.filter(src, dest);
> return dest;
> }
>
> public static void main(String args[]) throws Exception
> {
> ImageReader reader =
> ImageIO.getImageReadersByFormatName("JPEG").next();
> WritableRaster raster;
> FileInputStream fis = new FileInputStream("cmyk.jpg");
> try (ImageInputStream iis = new MemoryCacheImageInputStream(fis))
> {
> reader.setInput(iis);
> ImageReadParam irp = reader.getDefaultReadParam();
> raster = (WritableRaster) reader.readRaster(0, irp);
> }
> System.out.println("Raster: " + raster);
>
> ICC_Profile profile =
> ICC_Profile.getInstance("ISOcoated_v2_300_bas.icc");
> ICC_ColorSpace colorSpace = new ICC_ColorSpace(profile);
> long t0 = System.currentTimeMillis();
> for (int i = 0; i < 50; i++)
> {
> toRGBImageAWT(raster, colorSpace);
> }
> long t1 = System.currentTimeMillis();
> System.out.println((t1 - t0));
> }
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: dev-help@pdfbox.apache.org
>
>
Re: Rendering images from PDF files slower in OpenJDK
Posted by Tilman Hausherr <TH...@t-online.de>.
Am 03.10.2018 um 20:08 schrieb Tilman Hausherr:
>
> I could expand that one later so that it uses the raster of the actual
> JPEG image from your PDF.
Your JPEG file is here:
https://drive.google.com/file/d/1HvXMet6Wygzmko9ZmY9_zlvhv72v_QHf/view?usp=sharing
The modified code - please test on different openjdks. It took 137935 on
oracle jdk8. (you may want to change the "50")
import java.awt.*;
import java.awt.color.*;
import java.awt.image.*;
import java.io.FileInputStream;
import javax.imageio.ImageIO;
import javax.imageio.ImageReadParam;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import javax.imageio.stream.MemoryCacheImageInputStream;
public class CConv
{
static BufferedImage toRGBImageAWT(WritableRaster raster,
ColorSpace colorSpace)
{
ColorModel colorModel = new ComponentColorModel(colorSpace,
false, false, Transparency.OPAQUE,
raster.getDataBuffer().getDataType());
BufferedImage src = new BufferedImage(colorModel, raster,
false, null);
BufferedImage dest = new BufferedImage(raster.getWidth(),
raster.getHeight(),
BufferedImage.TYPE_INT_RGB);
ColorConvertOp op = new ColorConvertOp(null);
//System.out.println("src="+src);
//System.out.println("dst="+dest);
op.filter(src, dest);
return dest;
}
public static void main(String args[]) throws Exception
{
ImageReader reader =
ImageIO.getImageReadersByFormatName("JPEG").next();
WritableRaster raster;
FileInputStream fis = new FileInputStream("cmyk.jpg");
try (ImageInputStream iis = new MemoryCacheImageInputStream(fis))
{
reader.setInput(iis);
ImageReadParam irp = reader.getDefaultReadParam();
raster = (WritableRaster) reader.readRaster(0, irp);
}
System.out.println("Raster: " + raster);
ICC_Profile profile =
ICC_Profile.getInstance("ISOcoated_v2_300_bas.icc");
ICC_ColorSpace colorSpace = new ICC_ColorSpace(profile);
long t0 = System.currentTimeMillis();
for (int i = 0; i < 50; i++)
{
toRGBImageAWT(raster, colorSpace);
}
long t1 = System.currentTimeMillis();
System.out.println((t1 - t0));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org
Re: Rendering images from PDF files slower in OpenJDK
Posted by Tilman Hausherr <TH...@t-online.de>.
I'm confused by
http://mail.openjdk.java.net/pipermail/2d-dev/2018-October/009490.html
looking at the two graphics, in
http://cr.openjdk.java.net/~lbourges/pdfbox_profiles/jdk8_Call_Tree.html
the problem is that
"org.apache.pdfbox.pdmodel.graphics.color.PDDeviceCMYK.toRGBImage"
hasn't been expanded, maybe because it is so fast. I'd expect to see
ColorConvertOp there too. (I tried with jdk8 and it is there).
In the other graphic it was expanded and it is slow... for me the
culprit is (once again) ColorConvertOp and LCMS. It thought they had
fixed LCMS... it got much faster since 1.8.181.
Maybe the tool that creates these graphics expands only the slow parts,
to show devs "where it hurts".
SampledImageReader doesn't do anything OS dependent. I don't see why
there would be a "different path".
In
http://mail.openjdk.java.net/pipermail/2d-dev/2018-October/009498.html
there is a java program that does benchmarking (but with an blank
image!!!!!). Could you run this on your system?
I could expand that one later so that it uses the raster of the actual
JPEG image from your PDF.
Tilman
Am 03.10.2018 um 18:47 schrieb Daniel Persson:
> Hi everyone.
>
> I was doing some preparation to upgrade to OpenJDK 11 and found that image
> rendering was slower.
>
> I've talked about it here before but as it is a problem in the jvm I
> thought that opening a bug at oracle could be good.
>
> If interested you can follow the issue below:
>
> https://bugs.openjdk.java.net/browse/JDK-8211178
>
> Or following the 2d-dev mailing list at openjdk where we discuss our
> findings.
>
> Best regards
> Daniel
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org