Found an interesting performance bug: using `isIma...
# lucee
f
Found an interesting performance bug: using
isImageFile( url )
is several times slower than cfhttp + isImageFile( tempFile ) : https://luceeserver.atlassian.net/browse/LDEV-4177 so much so that it appears to request the url multiple times
while looking at the perf issue in the code, I found that isImageFile is just creating an image object and seeing if it throws an exception… it is probably doing a lot more work than necessary, for example if the orientation is not normal it will rotate the image:
The thing I noticed in the Image constructor was a call to checkOrientation() that was added in version 1.2.0.2 of the image extension:
https://github.com/lucee/extension-image/commit/b95a747617b33539b058e484f328c1f8ca94bc75#diff-2aeb88618768ab27ae1a96e1a2fe9711e32e5823dc53e4186490e87c6f084deaR201
The checkOrientation() function checks to see if the orientation is “NORMAL” and if not it calls changeOrientation(), which as you might guess will rotate the image:
https://github.com/lucee/extension-image/blob/5988b96110b43bc008d89c5a357007914b00e48b/source/java/src/org/lucee/extension/image/Image.java#L1224-L1246
b
I've seen this sort of thing before.
The extension thumbnail logic in the Lucee admin uses the same http resource and it's terribly inefficient.
If you have Fusionreactor, go to the "relations" tab and it will show you all the HTTP calls it makes behind the scenes. Usually some of them are
HEAD
request to do exists checks
@foundeo
z
exists().exists().exists().exists().exists().exists().
f
heh…
z
that said, asking if something is an image, rather than downloading it first is kinda silly, as you'll probably be doing something afterwards with it right?
f
I setup a requestbin url to test my assertion, you are right brad a bunch of HEAD requests in there:
but mostly get requests
@zackster yeah, it was a check to make sure the image url still works — easy to work around, but interesting issue none the less
z
totes
abstraction is cool, but sometimes expensive