Version 15 (modified by 7 years ago) (diff) | ,
---|
Packet Encoding and Compression
Bencode vs Rencode
Each packet exchanged between the client and server is encoded using one of those two stream encoders:
- The old bencode mode (see Bencode on wikipedia): a modified bencoder which supports non string keys in dictionaries, and support for unicode
- The newer/faster rencode mode, based on this version with minor tweaks/fixes
This allows various languages to implement the xpra protocol, specifying which encoder they want to use (bencode is more widely available than rencode).
As of v0.11, we also include a faster bencoder implemented in Cython: Cython vs Python bencoder
Pixels and Icons
Note: all window pixels, icons and cursors are sent using dedicated picture encodings and bypass the stream encoder completely (for efficiency). Pixel compression is done in its own thread, to improve responsiveness.
The only exception to this rule is the RGB
encoding, which will use the stream encoder on the raw pixels (but still called from the pixel compression thread).
Compression
The compression level can be specified via the command line ("-z LEVEL
" or "--compress=LEVEL
").
Here is what the LEVEL
does:
0
means no compression at all and is useful when bandwidth is no issue but latency is1
is the best trade-off and will compress everything but without making too much of an effort- values of 2 and above increase the compression (CPU usage and latency will increase) and should rarely be needed - the picture encoding used is much more important
lz4 vs zlib
As of version 0.11.0
, xpra supports lz4 compression and will use it instead of the default zlib when LEVEL
is set to 1 and both ends support the compression mode. More information here: #443
There is a benchmark test you can run to measure the performance of lz4 compared to zlib. On average, lz4 is at least 10 times faster than zlib on its fastest setting for regular packets, and even faster for RGB data (close to 20 times faster than zlib)
You can also find some more generic statistics here: lz4 vs zlib graphs
python-lz4 Installation
We have an python-lz4.spec rpm specfile and RPM
s should be available for Fedora
and CentOS
6.x in the RPM repository.
Other distributions can install from source: lz4
The MS Windows and Mac OSX binary installers include lz4.
Configuration
The default settings should end up using lz4
and rencode
, since those are by far the best options. That's why there are no command line options to change the defaults. The zlib
and bencode
options will remain for compatibility with clients which do not have support for them (ie: Android
, html5..).
However, you can disable individual encoders/compressors using environment variables:
XPRA_USE_LZ4=0 xpra ... XPRA_USE_BENCODER=0 xpra ... XPRA_USE_RENCODER=0 xpra ...
With v0.11 onwards, you can also change the current encoder/compressor at runtime:
- switch to zlib:
xpra control :DISPLAY compression zlib
- switch to lz4:
xpra control :DISPLAY compression lz4
- switch to bencode:
xpra control :DISPLAY encoder bencode
- switch to rencode:
xpra control :DISPLAY encoder rencode
More info on xpra control
here: #461.
You can view the current connection options with:
xpra info | egrep "connection.encoder=|connection.compression="