Bug 694514

Summary: severe performance degradation with banding
Product: Ghostscript Reporter: Henry Stiles <henry.stiles>
Component: Graphics LibraryAssignee: Ray Johnston <ray.johnston>
Status: NOTIFIED FIXED    
Severity: normal    
Priority: P4    
Version: 9.05   
Hardware: PC   
OS: All   
Customer: 460 Word Size: ---

Description Henry Stiles 2013-08-12 13:50:21 UTC
Created attachment 10108 [details]
slow file

gs -dMaxBitmap=1000000000 -sDEVICE=tiffg4 -r600 -o out.%d ~/BEAZH3P3.pdf

This 6 page job renders in about 30 seconds without banding and seems to go significantly longer than expect with banding (remove -dMaxBitmap argument)
Comment 1 Ray Johnston 2013-08-13 13:28:57 UTC
While the time _is_ longer without the -dMaxBitmap=1000000000 I do not see
anything like 83 minutes mentioned in the email. What vintage machine is
this?

With -dMaxBitmap=1000000000 I get 31 seconds (between 4 and 6 seconds per page)

If I use larger bands with -dBufferSpace=64m then it has 8 bands and takes 86
seconds, (between 13 and 15 seconds per page.)

Without it I see (using -Z:) that it has 129 bands and takes between 171 and
233 seconds per page, total time = 1109 seconds. I noticed that it is using
the pattern-clist, but setting -dMaxPatternBitmap=32m did not improve the
performance (but was large enough to not use the pattern-clist).

Changing the clist_begin_typed_image to use the default method for image
interpolation:
------------------------------
     if (pim->Interpolate)
-        pie->support.x = pie->support.y = MAX_ISCALE_SUPPORT + 1;
+        goto use_default;
------------------------------
reduces the run time with default clist mode to 15 seconds for page 1, and
the total job completes in 83 seconds. Adding -dBufferSpace=64m completes the
entire job in 35 seconds.

I think I need to add code that will be smarter about using HL images in the
clist when interpolating.
Comment 2 Ray Johnston 2013-08-13 14:00:49 UTC
When the clist device is "pattern-clist", then we don't what to interpolate
every time we paint the pattern-clist, since the 'support' requires doing
interpolation for many source image lines, and we are probably only painting
a fraction of it, particularly when the band size is small.

That's why the BufferSpace parameter improves this file -- less bands means
fewer number of times interpolating the pattern.

Testing the change to use the default image handling when the clist device
is the pattern-clist device and Interpolate is true.
Comment 3 Ray Johnston 2013-08-13 18:10:30 UTC
Fixed in commit 6c7d9d1
Comment 4 Ray Johnston 2020-02-07 02:53:29 UTC
Apparently improvements in the image interpolation has improved things so that
the patch to use default image processing when an interpolated image is
being processed into a pattern-clist.

With current HEAD (SHA e193b5d) this takes 23.3 seconds. With the patch removed
that restricts HL images to the pattern-clist, this file completes in 24.8
seconds.

With bug 702099, the pattern-clist (without HL images) uses > 500Mb, and the
file (a single page) takes 192 sec. Enabling HL images reduces the pattern-
clist to 1.2Mb and the page completes in 36 sec.