Re: Slow down when running newer Cairo on ARM with NEON

Bill Spitzak <[email protected]> Tue, 16 Apr 2019 12:01:22 -0700
Newsgroups gmane.comp.lib.cairo
Message-ID <CAL-8oAh8yiGJRQ=4kH5T2dVx53UFC=7trHxMxNeengt0BL2f3g@mail.gmail.com>
--===============0801486607==
Content-Type: multipart/alternative; boundary="000000000000c0bfb60586aa65bf"

--000000000000c0bfb60586aa65bf
Content-Type: text/plain; charset="UTF-8"

I think you can force the interpolation to bilinear or impulse. However you
are going to revert to 1980's style scaling with extreme aliasing.

This is some of my work from 4 years ago and unfortunately it never got
finished due to rejection by the Pixman maintainers (who I think may not be
working on it any more). This was to implement a two-pass algorithm in
Pixman that could also do non-affine (perspective) transforms. It should be
considerably faster for any down-scaling, even if the filter is set to
bilinear. The current code is not 2-pass (in effect both passes are run for
every output pixel, rather than saving the result of the first pass, this
is in fact worse than convolving with a 2-D filter), but at least produces
modern results.

The problem is that the filters cannot be specified as arrays of weights,
due to the need to choose arbitrary filter sizes, both to allow non-affine
transforms and just because most 2-pass algorithms require unexpected
filter sizes (such as the derivative along the x axis of the input but the
y axis of the output). IMHO the most practical way to get this is to just
make "GOOD" and "BEST" select two implementation-chosen filters (BILINEAR
and IMPULSE would also be allowed) and scrap any ability to specify the
filter more accurately by the client. This seemed to produce considerable
pushback in pixman and was rejected and I gave up after succeeding in
getting the api implemented in Cairo.


On Tue, Apr 16, 2019 at 10:38 AM Joshua Watt <[email protected]> wrote:

> Hello,
>
> I recently upgrade from Cairo 1.12 to 1.14 (yes, I know these are old
> versions), and after doing so noticed a approximately 70% reduction in
> performance when rendering scenes that make heavy use of image scaling.
> I did some digging and tracking the offending commit down to the
> commit: f337342c8 ("V6 image: Use convolution filters for sample
> reconstruction when downscaling")
>
> It appears that this commit is attempting to improve the quality of
> downscaled images by implementing new interpolation algorithms in cairo
> instead of using the pixman algorithms. My theory is that this is much
> slower on ARM processes that have NEON support because pixman has
> special implementations of the interpolations algorithms written to
> take advantage of NEON, while the new cairo implementations do not.
>
> Does anyone have any ideas on what a good path forward would be to
> restore the ARM+NEON performance? I am planning on trying to reproduce
> this with a newer version of cairo to see if it is still a problem, but
> I suspect it will be based on the lack of any significant changes in
> this code to either cairo or pixman.
>
> --
> Joshua Watt <[email protected]>
>
> --
> cairo mailing list
> [email protected]
> https://lists.cairographics.org/mailman/listinfo/cairo

--000000000000c0bfb60586aa65bf
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr">I think you can force the interpolation t=
o bilinear or impulse. However you are going to revert to 1980&#39;s style =
scaling with extreme aliasing.<div><br></div><div>This is some of my work f=
rom 4 years ago and unfortunately it never got finished due to rejection by=
 the Pixman maintainers (who I think may not be working on it any more). Th=
is was to implement a two-pass algorithm in Pixman that could also do non-a=
ffine (perspective) transforms. It should be considerably faster for any do=
wn-scaling, even if the filter is set to bilinear. The current code is not =
2-pass (in effect both passes are run for every output pixel, rather than s=
aving the result of the first pass, this is in fact worse than convolving w=
ith a 2-D filter), but at least produces modern results.</div><div><br></di=
v><div>The problem is that the filters cannot be specified as arrays of wei=
ghts, due to the need to choose arbitrary filter sizes, both to allow non-a=
ffine transforms and just because most 2-pass algorithms require unexpected=
 filter sizes (such as the derivative along the x axis of the input but the=
 y axis of the output). IMHO the most practical way to get this is to just =
make &quot;GOOD&quot; and &quot;BEST&quot; select two implementation-chosen=
 filters (BILINEAR and IMPULSE would also be allowed) and scrap any ability=
 to specify the filter more accurately by the client. This seemed to produc=
e considerable pushback in pixman and was rejected and I gave up after succ=
eeding in getting the api implemented in Cairo.</div><div><br></div></div><=
/div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">O=
n Tue, Apr 16, 2019 at 10:38 AM Joshua Watt &lt;<a href=3D"mailto:jpewhacke=
[email protected]">[email protected]</a>&gt; wrote:<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex">Hello,<br>
<br>
I recently upgrade from Cairo 1.12 to 1.14 (yes, I know these are old<br>
versions), and after doing so noticed a approximately 70% reduction in<br>
performance when rendering scenes that make heavy use of image scaling.<br>
I did some digging and tracking the offending commit down to the<br>
commit: f337342c8 (&quot;V6 image: Use convolution filters for sample<br>
reconstruction when downscaling&quot;)<br>
<br>
It appears that this commit is attempting to improve the quality of<br>
downscaled images by implementing new interpolation algorithms in cairo<br>
instead of using the pixman algorithms. My theory is that this is much<br>
slower on ARM processes that have NEON support because pixman has<br>
special implementations of the interpolations algorithms written to<br>
take advantage of NEON, while the new cairo implementations do not.<br>
<br>
Does anyone have any ideas on what a good path forward would be to<br>
restore the ARM+NEON performance? I am planning on trying to reproduce<br>
this with a newer version of cairo to see if it is still a problem, but<br>
I suspect it will be based on the lack of any significant changes in<br>
this code to either cairo or pixman.<br>
<br>
-- <br>
Joshua Watt &lt;<a href=3D"mailto:[email protected]" target=3D"_blank">J=
[email protected]</a>&gt;<br>
<br>
-- <br>
cairo mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank">cairo@cairogra=
phics.org</a><br>
<a href=3D"https://lists.cairographics.org/mailman/listinfo/cairo" rel=3D"n=
oreferrer" target=3D"_blank">https://lists.cairographics.org/mailman/listin=
fo/cairo</a></blockquote></div>

--000000000000c0bfb60586aa65bf--

--===============0801486607==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

LS0gCmNhaXJvIG1haWxpbmcgbGlzdApjYWlyb0BjYWlyb2dyYXBoaWNzLm9yZwpodHRwczovL2xp
c3RzLmNhaXJvZ3JhcGhpY3Mub3JnL21haWxtYW4vbGlzdGluZm8vY2Fpcm8=

--===============0801486607==--