JDK-6309072 : ImageIO write from remote display too slow
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Affected Version: 5.0
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_8
  • CPU: sparc
  • Submitted: 2005-08-10
  • Updated: 2010-04-02
  • Resolved: 2005-08-10
Related Reports
Duplicate :  
Description
A customer encounters a performance problem with ImageIO.
Using the attached test case, here the time it takes to write an image
to a file (PNG):

  local display -> DISPLAY set to :0
  remote display -> DISPLAY set to remote machine:0

                  local display	  remote display
  jdk1.5.0_04	   ~3 sec		~36 min
  jdk1.4.2_08	   ~3 sec		~39 min


pstack shows the following:

  ...
  b2bc047c XGetImage (1c4128, e0002f, 2e2, 4d, 1, 1) + a0
  fde27ea0 ???????? (fde75940, 2a36a8, ffbfd9c0, 1, 0, 20) + 4b267ac4
  fde27c38 ???????? (37618, 2a36a8, ffbfd9c0, 1c6170, 1, 3c4) + 4b26785c
  b30f5d44 Java_sun_awt_image_DataBufferNative_getElem (37618, ffbfda98, 2e2, 4d, ffbfda94, 2a36a8) + 64
  f8850798 * *sun/awt/image/DataBufferNative.getElem(IILsun/java2d/SurfaceData;)I+0
  f8850c10 * sun/awt/image/IntegerInterleavedRaster.verify(Z)V+432 (line 551)
  f8851720 * *java/awt/image/SinglePixelPackedSampleModel.getDataElements(IILjava/lang/Object;Ljava/awt/image/DataBuffer;)Ljava/lang/Object;+196 (line 404)
  f8857404 * *java/awt/image/SampleModel.getDataElements(IIIILjava/lang/Object;Ljava/awt/image/DataBuffer;)Ljava/lang/Object;+369 (line 402)
   ...


I tracked down (jdk1.5.0_04 src) to the following call where
getDataElements is eventually called for each pixel. In the remote case,
it further translates to XGetImage call per pixel, which could be
the cause for bad performance:


SampleModel:
334 public Object getDataElements(getDataElements(int x, int y, int w, int h,
335				  Object obj, DataBuffer data) {:
....

400	 for (int i=y; i<y+h; i++) {
401	    for (int j=x; j<x+w; j++) {
402		o = getDataElements(j, i, o, data);
403		itemp = (int[])o;
404		for (int k=0; k<numDataElems; k++) {
405		idata[cnt++] = itemp[k];
406	    }
407	 }

Comments
EVALUATION This is essentially a duplicate of 4835595. See work around field for a couple different ways to avoid this performance issue. It seems more and more customers are running into this issue nowadays, so we will be looking into ways to solve this in the near future.
10-08-2005

WORK AROUND Another workaround is to use the -Dsun.java2d.pmoffscreen=false system property, which disables our use of pixmaps and eliminates the performance issue.
10-08-2005

WORK AROUND workaround provided by Dan Rice -- to replace: //imageBuf = (BufferedImage)(this.createImage(width, height)); with imageBuf = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); in the attached program.
10-08-2005