xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Changes between Initial Version and Version 1 of Ticket #1075


Ignore:
Timestamp:
01/05/16 16:30:15 (5 years ago)
Author:
Antoine Martin
Comment:

Negotiating the muxers would have made the code very very hard to maintain, and there is a much easier solution implemented in r11594 + r11596: we add some new virtual codecs named "flac+gdp", "opus+gdp" and "speex+gdp".

I now get on Fedora 23:

./xpra/sound/gstreamer_util.py
(...)

GStreamer version: 1.6.2.0
PyGStreamer version: 3.18.2

encoders supported: vorbis, opus+gdp, opus, flac+gdp, mp3, wav, wavpack, speex+gdp, speex
decoders supported: vorbis, opus+gdp, opus, flac+gdp, mp3, wav, wavpack, speex+gdp, speex
source plugins: pulsesrc, autoaudiosrc, alsasrc, osssrc, oss4src, audiotestsrc
sink plugins: autoaudiosink, pulsesink, alsasink, osssink, oss4sink
default sink: pulsesink

With this in place, we now prefer the "gdp" muxer variant for "opus", "flac" and "speex" if both ends support it. And if we end up making opus the default (#1074), we will just have "opus+gdp" first in the list.


Having some hard data to verify that gdp is really better than ogg would be useful too, though that's going to be hard to measure (everything else would need to be turned off: no screen updates, just sound), I would expect:

  • the bandwidth usage to be marginally lower (maybe more so when the sound compresses very well, ie: silence rather than music)
  • the CPU usage to also be lower (by a very small margin..)
  • latency should be lower too (though ogg's 20ms is pretty low already - not sure how to measure that)

If possible, it is better to completely remove xpra from the equation for making measurements. For example we can run the gstreamer pipelines standalone. After running the server with -d sound we can see in the log output that the pipeline used for "opus+gdp" is:

sound source pipeline=pulsesrc device=alsa_output.pci-0000_00_14.2.analog-stereo.monitor ! \
    queue name=queue min-threshold-time=0 max-size-buffers=0 max-size-bytes=0 max-size-time=50000000 leaky=2 silent=1 ! \
    volume name=volume volume=1.0 ! opusenc cbr=0 complexity=0 ! \
    gdppay crc-payload=0 crc-header=0 ! \
    appsink name=sink emit-signals=true max-buffers=10 drop=true sync=false async=false qos=false

Then we can replace the source with a test "audiotestsrc" and the pulsesink with a "fakesink". Script the whole thing to run for 10 seconds and measure CPU usage with time:

time gst-launch-1.0 audiotestsrc ! \
    queue name=queue min-threshold-time=0 max-size-buffers=0 max-size-bytes=0 max-size-time=50000000 leaky=2 silent=1 ! \
    volume name=volume volume=1.0 ! opusenc cbr=0 complexity=0 ! \
    gdppay crc-payload=0 crc-header=0 ! fakesink &
sleep 10;killall gst-launch-1.0

Then we can repeat this process for all the different codecs... both client and server. (and if we wanted to, we could even test gstreamer 0.10 vs 1.x by replacing gst-launch-1.0 by gst-launch-0.10).

If we wanted to be really thorough, we could also change the audiotestsrc to produce different types of test sounds, ie: to get silence: audiotestsrc wave=4 (more info here: http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-audiotestsrc.html). Or even feeding a specific music sampled as input using filesrc.

For more information on the output of time, see Real, User and Sys process time statistics. Ideally we would get more detailed statistics using a tool like perf, but this will do for now.

So far I got:

Client or Server Codec Real CPU User CPU Sys CPU
Server opus+gdp 10.0 19.9 ~0.04 +- 0.02
Server opus 10.0 19.9 0.09 +- 0.02

So that's a very small win for gdp, which is spending less time in kernel mode, probably because it does not rely on timers for chunking the data.


@afarr: please test that you can select the new "+gdp" codec options, unless you have lots of spare time and feel like compiling lots of interesting numbers as I started doing above...

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #1075

    • Property Owner changed from Antoine Martin to alas
  • Ticket #1075 – Description

    initial v1  
    33It would be nice if the client and server could negotiate which muxers they want to use so that we can use gdppay / gdpdepay instead of ogg.
    44Ogg is heavier and adds latency.
    5 Especially for opus (#1074).
     5Especially for opus (#1074). This builds on the work done in #849.