[Geoserver-users] Potentially Slow Mosaic Performance in directRasterRender

Some background: we are running GeoServer 2.7.2 and the map client is sending
WMS GetMap requests for PNG output with transparent=TRUE against raster data
using a simple ColorMap SLD and both tiled and non-tiled requests have been
tested.

We've noticed that the response time increases significantly when the map is
zoomed in far enough that the size of the bounding box in the GetMap request
is smaller than the resolution of a grid point in the original raster data
(e.g., a request with maxx-minx and maxy-miny is 0.01 degrees against a 1
degree resolution grid). In our case, the response time can jump from
<100ms to almost 5 seconds.

After doing some profiling and debugging, we were able to track the slow
performance down to the Mosaic operation at the end of
org.geoserver.wms.map.RenderedImageMapOutputFormat.directRasterRender. I've
looked at the code and I think that the ROI may not be set up correctly for
cases where the Mosaic operation has to crop the image. The following
change results in more reasonable response times for these requests:

replace this:
ROI rois = new ROI { new ROIShape(imageBounds) };

with this:
Rectangle roi = imageBounds.contains(mapRasterArea) ? mapRasterArea :
imageBounds;
ROI rois = new ROI { new ROIShape(roi) };

Using imageBounds.intersection(mapRasterArea) may also work.

I've been able to reproduce this using the sample GeoTIFF image
src/main/src/test/java/org/geoserver/data/test/world.tiff (a ColorMap SLD
must be used). I've only done some testing on 2.7.x but this appears to be
applicable to 2.8.x and master. Any thoughts?

Steve Ikeoka

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Potentially-Slow-Mosaic-Performance-in-directRasterRender-tp5241258.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Also, this was tested with both bilinear and nearest neighbor interpolation
and with mosaic native acceleration enabled and disabled.

After more testing, I was able to track the slow performance down
specifically to the javax.media.jai.ROIShape.getAsImage() call that occurs
inside the com.sun.media.jai.opimage.MosaicOpImage constructor. Using the
smaller ROI improves the performance of that specific method call while the
rest of the Mosaic operation is not noticeably impacted by which ROI is
used.

Steve Ikeoka

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Potentially-Slow-Mosaic-Performance-in-directRasterRender-tp5241258p5241296.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Hi Steve,
we haven’t noticed a performance problem there so far, but I’m working on a OOM
caused by that same method, ROIShape.getImage()… the OOM in question is of the
“strange” kind, cause by the finalization queue not clearing fast enough the
WrappedRenderedImageAdapter that are eventually generated by calling ROIShape.getImage(),
under heavy WCS load (with mosaics).

The last mosaic operation in the WMS rendering chain is a different beast though… are you
making very large requests to the WMS? Or I guess, you’re trying to serve a very large GeoTiff?
Anyways, what that operation is trying to do, is to apply the background color in the output
image in case that:

  • the input one has a transparency, but the output is opaque
  • the input image is smaller than the output (this will apply background and collar at the same time)

I don’t have enough time to reason properly about this issue, just trying to answer quickly (might
be days before I can dedicate more attention to this one), but I would check if doing an
intersection between the image bounds and the map bounds would work better.

Steve, once you’re done, can add a test you make a pull request to get this change in?
https://github.com/geoserver/geoserver/blob/master/CONTRIBUTING.md

Cheers
Andrea

···

On Mon, Dec 14, 2015 at 9:34 PM, sikeoka <steve.ikeoka@anonymised.com…> wrote:

Also, this was tested with both bilinear and nearest neighbor interpolation
and with mosaic native acceleration enabled and disabled.

After more testing, I was able to track the slow performance down
specifically to the javax.media.jai.ROIShape.getAsImage() call that occurs
inside the com.sun.media.jai.opimage.MosaicOpImage constructor. Using the
smaller ROI improves the performance of that specific method call while the
rest of the Mosaic operation is not noticeably impacted by which ROI is
used.

Steve Ikeoka


View this message in context: http://osgeo-org.1560.x6.nabble.com/Potentially-Slow-Mosaic-Performance-in-directRasterRender-tp5241258p5241296.html

Sent from the GeoServer - User mailing list archive at Nabble.com.



Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

==
GeoServer Professional Services from the experts! Visit
http://goo.gl/it488V for more information.

Geosolutions’ Winter Holidays from 24/12 to 6/1

Ing. Andrea Aime

@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy’s New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.


I found out that this issue will not happen when advanced projection handling
is enabled because the GridCoverageRenderer method that is used in that path
will always crop its final image. I was only able to reproduce this in a
unit test by adding a @BeforeClass method with:
System.setProperty("ENABLE_ADVANCED_PROJECTION", "false");

Changing imageBounds to imageBounds.intersection(mapRasterArea) in the
Mosaic ROI does appear to fix this particular issue.

Steve Ikeoka

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Potentially-Slow-Mosaic-Performance-in-directRasterRender-tp5241258p5241690.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

On Thu, Dec 17, 2015 at 12:35 AM, sikeoka <steve.ikeoka@anonymised.com> wrote:

I found out that this issue will not happen when advanced projection
handling
is enabled because the GridCoverageRenderer method that is used in that
path
will always crop its final image.

Ah, that explains why I never saw this issue, I never run with that flag
disabled

  I was only able to reproduce this in a
unit test by adding a @BeforeClass method with:
System.setProperty("ENABLE_ADVANCED_PROJECTION", "false");

Changing imageBounds to imageBounds.intersection(mapRasterArea) in the
Mosaic ROI does appear to fix this particular issue.

Good to know... still have to do some research to verify there are no other
ill side effects.
Could you open a bug report at
https://osgeo-org.atlassian.net/projects/GEOS/summary ?

Cheers
Andrea

--

GeoServer Professional Services from the experts! Visit
http://goo.gl/it488V for more information.

*Geosolutions' Winter Holidays from 24/12 to 6/1*

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

*AVVERTENZE AI SENSI DEL D.Lgs. 196/2003*

Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.

-------------------------------------------------------