Improved Support for Wan
In a limited network resources environment, we would like to achieve a user-experience which is similar as possible to the LAN experience. In order to achieve this we need to improve Spice bandwidth utilization, with a reasonable cost of more CPU utilization. The core of this feature is reaching a better compression ratio for bitmaps that are sent from the server to the client.
- Targeted Release: spice-0.6
Today, bitmaps that are sent from the server to the client can be compressed by one of two algorithms: QUIC or GLZ. QUIC is based on predictive coding. GLZ is an LZ algorithm that is adjusted to pixels and uses a wide window which incorporates a stream of images, thus both repetition within and among images can be utilized for encoding. The choice of the compression algorithm is performed heuristically, according to the bitmap's features: a photo-like bitmap will be compressed by QUIC, while a more artificial bitmap will be compressed by GLZ. Both of the algorithms are lossless.
Main steps for improving the WAN experience include:
- Compressing photo-like bitmaps with a lossy algorithm (in WAN). For photo-like bitmaps, using other lossless algorithm, e.g., JPEG-LS, haven't showed a significant improvement in compression ratio; while by employing JPEG (which is lossy), we can achieve and improvement of > 50% for these bitmaps. However, this strategy may introduce a overhead: the server sends rendering commands, and not just bitmaps to draw over the canvas. Thus, in order to avoid noticeable artifacts in the display, we can't compress all the bitmaps using JPEG, and we might also need to resend surfaces areas and cached bitmaps to the client. For example, in a draw-transparent command, we receive a source bitmap (or a reference to a surface), and a color pixel, for ignoring all the pixels with this color. Compressing this bitmap using JPEG, will result in a bitmap with different pixels, thus, in order to avoid distortion, we must use lossless compression. Moreover, if the bitmap is only a reference to a surface, we will need to resend the corresponding bitmap to the client. This yet introduces another complication - the surfaces in the server side might be more updated than the ones in the client side, thus the server might not hold the data that needs to be resent. We can overcome this by replacing commands that are going to be sent to the client, with the draw copy commands of the relevant areas. For avoiding large overhead, we may develop a heuristic for identifying bitmaps that are pruned to be utilized in their lossless form, and thus should be compressed by QUIC.
- Adding an entropy-based compression layer over GLZ. JPEG is not well suited for Artificial/Textual bitmaps. Such bitmaps will be still compressed by GLZ, but we will incorporate an additional compression algorithm over GLZ. Preliminary tests showed we can reach a compression ratio improvement of >20%.
- Other capabilities
- splitting large images to small rectangles: This will improve the responsiveness of Spice and will also allow us to compress different areas in one image by different algorithms, that are more suitable for them.
- Automatically configuring the desktop features (e.g., color depth) according to the network availability.