[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#972943: libtheora0: Too easy to enable "telemetry" (statistics capture) by mistake, causing poor performance



Control: tags -1 - patch

On 2020-10-26 13:19:36 +0000, Simon McVittie wrote:
> Package: libtheora0
> Version: 1.1.1+dfsg.1-11
> Severity: normal
> Tags: patch fixed-upstream
> Forwarded: https://gitlab.xiph.org/xiph/theora/-/issues/2312
> 
> The latest version of Proton (Valve's branch of Wine, used to run Windows
> games under Steam) runs in a Debian 10-based container
> (Steam Runtime 2 'soldier'), instead of the Ubuntu 12.04-based
> LD_LIBRARY_PATH library bundle (Steam Runtime 1 'scout') that was used
> in previous releases.
> 
> During the move from Steam Runtime 1 to 2, Proton developers noticed
> a performance regression in their GStreamer-based video decoding,
> which they were able to track down to the theoradec plugin. This plugin
> uses libtheora, which has an optional feature called "telemetry" that
> records statistics. It can be enabled or disabled at build-time; if
> enabled at build-time, it is disabled by default at runtime. Activating
> it at runtime involves setting some options, and incurs a significant
> performance cost to convert each decoded frame from YUV to RGB for use
> by Cairo (30-40ms per frame for 1920x1080 video).
> 
> Note that despite its name, as far as I'm aware "telemetry" does not
> send the statistics anywhere, it just captures them - so it isn't a
> privacy problem, and is really just "-metry", with no "tele-" involved :-)
> 
> In Debian, the telemetry feature is enabled in libtheora at build-time
> since 1.1.1+dfsg.1-11, as requested in
> <https://bugs.launchpad.net/ubuntu/+source/libtheora/+bug/627854>.
> 
> GStreamer's theoradec plugin attempts to set the telemetry options to
> user-specified values.  However, in released versions of libtheora,
> setting the telemetry options to any value - even 0 - is documented to
> have the side-effect of enabling the telemetry feature and triggering
> the performance regression.
> 
> This can be fixed in three ways:
> 
> 1. Disable telemetry at compile-time in libtheora.
>    We did this in the Steam Runtime as a temporary solution, but it's a
>    feature regression for libtheora, and the libtheora maintainers in
>    Debian presumably don't want that, so let's discard this option.
> 
> 2. In GStreamer, if the telemetry options are set to 0, don't propagate
>    that into libtheora so that the expensive YUV -> RGB conversion is
>    not done, even with current releases of libtheora. This is
>    <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/887>
>    and I've filed a separate Debian bug for it. The patch has been merged
>    upstream and was backported to 1.18.x (for 1.18.1, I think) in
>    <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/892>.
> 
> 3. In libtheora, if the telemetry options are all explicitly set to 0
>    (for example by current versions of GStreamer), behave as though they
>    had not been set at all, and therefore don't enable the expensive
>    YUV -> RGB conversion. This is
>    <https://gitlab.xiph.org/xiph/theora/-/issues/2312> and
>    <https://gitlab.xiph.org/xiph/theora/-/merge_requests/4>, and is what
>    this bug report represents. The patch has been merged upstream for
>    v1.2.0, but there hasn't been an upstream release since 1.2.0 alpha 1
>    (which doesn't have this change) in 2010, so it seems unlikely that
>    there will be a release with this change any time soon.

FWIW, the upstream change does not apply to 1.1.1 and needs to be
adapted accordingly. th_decode_packetin seems to be sufficently
different that I leave that to someone with some deeper knowledge of the
code.

Cheers

> 
> Following the principle that bad interactions between two components are
> most robust if fixed on *both* sides, solutions 2 and 3 have both been
> accepted upstream, and I suggest that they should also happen in Debian.
> 
> The Steam Runtime maintainers will probably be doing a backport of this
> into 1.1.1, so I'll try to send a patch later.
> 
> Thanks,
>     smcv
> 

-- 
Sebastian Ramacher

Attachment: signature.asc
Description: PGP signature


Reply to: