Bug 7104 - GD image resizing is painfully slow
: GD image resizing is painfully slow
Status: CLOSED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Misc
: 7.0
: Macintosh Other
: P1 major with 1 vote (vote)
: 7.x
Assigned To: Andy Grundman
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-02-12 14:36 UTC by Andy Grundman
Modified: 2009-09-08 09:21 UTC (History)
4 users (show)

See Also:
Category: ---


Attachments
GD benchmark script (967 bytes, text/plain)
2008-02-12 14:39 UTC, Andy Grundman
Details
Image used for my benchmark (31.07 KB, image/jpeg)
2008-02-12 15:52 UTC, Andy Grundman
Details
GD benchmark script (1.05 KB, text/plain)
2008-02-12 21:09 UTC, Andy Grundman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Grundman 2008-02-12 14:36:21 UTC
I benchmarked the GD operations we perform for every image resize and my 3Ghz server can only do 15/second.  The big problem is copyResampled().  Need to find a faster way of doing our resize.
Comment 1 Andy Grundman 2008-02-12 14:39:24 UTC
Created attachment 2848 [details]
GD benchmark script

My benchmark script.  The Imager section was to see if the Imager filtering we're doing on Windows was causing any performance impact, the answer to that question is no.
Comment 2 KDF 2008-02-12 14:39:55 UTC
see also bug 7087
Comment 3 Adrian Smith 2008-02-12 15:09:08 UTC
Something strange going on here Andy, your script gives the following for me:

Benchmark: running gd, imager for at least 5 CPU seconds...
        gd:  5 wallclock secs ( 5.03 usr +  0.08 sys =  5.11 CPU) @ 25.83/s (n=132)
    imager:  5 wallclock secs ( 5.21 usr +  0.13 sys =  5.34 CPU) @ 37.08/s (n=198)

Different image:
        gd:  5 wallclock secs ( 5.26 usr +  0.04 sys =  5.30 CPU) @ 13.58/s (n=72)
    imager:  5 wallclock secs ( 4.98 usr +  0.15 sys =  5.13 CPU) @ 10.53/s (n=54)

So imager can be slow?
Comment 4 Andy Grundman 2008-02-12 15:52:32 UTC
Created attachment 2853 [details]
Image used for my benchmark

Here's the file I used for my benchmark, a 512x512 jpeg.  I figure it's a pretty normal sized file similar to what people will have.
Comment 5 Andy Grundman 2008-02-12 16:15:21 UTC
Update to my benchmark, the Imager filter is also really slow, but we can't really do anything about that right now.
Comment 6 Blackketter Dean 2008-02-12 19:26:10 UTC
Is 15/sec really that slow?  This is all cached, so it's a one-time hit...
Comment 7 KDF 2008-02-12 20:29:46 UTC
not for those who rescan daily (there ARE those that do), nor for those of us who have to hear the complaints as people focus on timing the scans :)
Comment 8 Andy Grundman 2008-02-12 21:09:30 UTC
Created attachment 2854 [details]
GD benchmark script

Fixed version of benchmark script
Comment 9 Andy Grundman 2008-02-12 21:32:37 UTC
Note to self: pre-caching should only cache one image per album, not one image per track.
Comment 10 Blackketter Dean 2008-02-12 22:15:04 UTC
A regular rescan should not regenerate all the image data.

A daily wipe-and-rescan shouldn't be necessary for anybody but the most insane.  
Comment 11 KDF 2008-02-12 22:17:03 UTC
using attached image:

Benchmark: running gd, imager for at least 5 CPU seconds...
        gd:  5 wallclock secs ( 4.98 usr +  0.02 sys =  5.00 CPU) @ 10.00/s (n=50)
    imager:  5 wallclock secs ( 5.44 usr +  0.10 sys =  5.54 CPU) @ 19.13/s (n=106)

model name	: AMD Athlon(tm) 64 X2 Dual Core Processor 3600+
cpu MHz		: 1908.768
cache size	: 512 KB

Comment 12 Andy Grundman 2008-02-13 07:01:27 UTC
The first thing I'm going to work on in trunk is requesting cover images without an extension and serving the best type of  file.  This means square images can be jpeg which processes a bit faster than png, and results in much smaller files.
Comment 13 Adrian Smith 2008-02-13 11:04:59 UTC
I think we should offer a preference to avoid doing all this work at artwork scan time.  I feel this could be something like the original cache implementation which caused lots of feedback once 6.5 was launched.  If its possible for it to take an hour to do an artwork scan we need to do something about it...

I'd also note that we have effectively halved performance for windows because a few users had crashes - is this the right trade off?
Comment 14 Andy Grundman 2008-03-25 07:49:04 UTC
Checked in my serve-square-JPEG-as-JPEG fix as change 17980.  Also serves JPEG to Jive for those images.  The Jive performance seems OK to me but could use some benchmarking.
Comment 15 Andy Grundman 2008-03-28 11:13:52 UTC
Marking fixed, we can't really speed up GD but we have improved Jive and web speed by using JPEG.
Comment 16 James Richardson 2008-05-08 13:43:43 UTC
(In reply to comment #15)
> Marking fixed, we can't really speed up GD but we have improved Jive and web
> speed by using JPEG.
> 

Closing bug
Comment 17 Chris Owens 2009-07-31 10:17:04 UTC
Reduce number of active targets for SC