[Spice-devel] [PATCH spice 3/3] compress-stat: Add not compressed image to statistics
Frediano Ziglio
fziglio at redhat.com
Tue Feb 16 12:00:55 UTC 2016
>
> To see how many images and data could not be compressed.
> ---
> server/dcc.c | 32 +++++++++++++++++++++++---------
> server/display-channel.c | 11 +++++++++++
> server/display-channel.h | 1 +
> 3 files changed, 35 insertions(+), 9 deletions(-)
>
> diff --git a/server/dcc.c b/server/dcc.c
> index c63f6c1..3e71c36 100644
> --- a/server/dcc.c
> +++ b/server/dcc.c
> @@ -1191,44 +1191,58 @@ int dcc_compress_image(DisplayChannelClient *dcc,
> {
> DisplayChannel *display_channel = DCC_TO_DC(dcc);
> SpiceImageCompression image_compression;
> + stat_start_time_t start_time;
> + int success = FALSE;
> +
> + stat_start_time_init(&start_time, &display_channel->off_stat);
>
> image_compression = get_compression_for_bitmap(src,
> dcc->image_compression, drawable);
> switch (image_compression) {
> case SPICE_IMAGE_COMPRESSION_OFF:
> - return FALSE;
> + break;
> case SPICE_IMAGE_COMPRESSION_QUIC:
> if (can_lossy && display_channel->enable_jpeg &&
> (src->format != SPICE_BITMAP_FMT_RGBA ||
> !bitmap_has_extra_stride(src))) {
> - return dcc_compress_image_jpeg(dcc, dest, src, o_comp_data);
> + success = dcc_compress_image_jpeg(dcc, dest, src, o_comp_data);
> + break;
> }
> - return dcc_compress_image_quic(dcc, dest, src, o_comp_data);
> + success = dcc_compress_image_quic(dcc, dest, src, o_comp_data);
> + break;
> case SPICE_IMAGE_COMPRESSION_GLZ:
> if ((src->x * src->y) <
> glz_enc_dictionary_get_size(dcc->glz_dict->dict)) {
> - int ret, frozen;
> + int frozen;
> /* using the global dictionary only if it is not frozen */
> pthread_rwlock_rdlock(&dcc->glz_dict->encode_lock);
> frozen = dcc->glz_dict->migrate_freeze;
> if (!frozen) {
> - ret = dcc_compress_image_glz(dcc, dest, src, drawable,
> o_comp_data);
> + success = dcc_compress_image_glz(dcc, dest, src, drawable,
> o_comp_data);
> }
> pthread_rwlock_unlock(&dcc->glz_dict->encode_lock);
> if (!frozen) {
> - return ret;
> + break;
> }
> }
> #ifdef USE_LZ4
> case SPICE_IMAGE_COMPRESSION_LZ4:
> if (red_channel_client_test_remote_cap(&dcc->common.base,
> SPICE_DISPLAY_CAP_LZ4_COMPRESSION))
> {
> - return dcc_compress_image_lz4(dcc, dest, src, o_comp_data);
> + success = dcc_compress_image_lz4(dcc, dest, src, o_comp_data);
> + break;
> }
> #endif
> case SPICE_IMAGE_COMPRESSION_LZ:
> - return dcc_compress_image_lz(dcc, dest, src, o_comp_data);
> + success = dcc_compress_image_lz(dcc, dest, src, o_comp_data);
> + break;
> default:
> spice_error("invalid image compression type %u", image_compression);
> }
> - return FALSE;
> +
> + if (!success) {
> + uint64_t image_size = src->stride * src->y;
> + stat_compress_add(&display_channel->off_stat, start_time,
> image_size, image_size);
> + }
> +
> + return success;
> }
>
> #define CLIENT_PALETTE_CACHE
> diff --git a/server/display-channel.c b/server/display-channel.c
> index 82dbe03..3b5e169 100644
> --- a/server/display-channel.c
> +++ b/server/display-channel.c
> @@ -36,6 +36,7 @@ void display_channel_compress_stats_reset(DisplayChannel
> *display)
> {
> spice_return_if_fail(display);
>
> + stat_reset(&display->off_stat);
> stat_reset(&display->quic_stat);
> stat_reset(&display->lz_stat);
> stat_reset(&display->glz_stat);
> @@ -58,6 +59,12 @@ void display_channel_compress_stats_print(const
> DisplayChannel *display_channel)
>
> spice_info("==> Compression stats for display %u",
> display_channel->common.base.id);
> spice_info("Method \t count
> \torig_size(MB)\tenc_size(MB)\tenc_time(s)");
> + spice_info("OFF \t%8d\t%13.2f\t%12.2f\t%12.2f",
> + display_channel->off_stat.count,
> + stat_byte_to_mega(display_channel->off_stat.orig_size),
> + stat_byte_to_mega(display_channel->off_stat.comp_size),
> + stat_cpu_time_to_sec(display_channel->off_stat.total)
> + );
> spice_info("QUIC \t%8d\t%13.2f\t%12.2f\t%12.2f",
> display_channel->quic_stat.count,
> stat_byte_to_mega(display_channel->quic_stat.orig_size),
> @@ -103,18 +110,21 @@ void display_channel_compress_stats_print(const
> DisplayChannel *display_channel)
> spice_info("-------------------------------------------------------------------");
> spice_info("Total \t%8d\t%13.2f\t%12.2f\t%12.2f",
> display_channel->lz_stat.count +
> display_channel->glz_stat.count +
> +
> display_channel->off_stat.count
> +
> display_channel->quic_stat.count
> +
> display_channel->jpeg_stat.count
> +
> display_channel->lz4_stat.count
> +
> display_channel->jpeg_alpha_stat.count,
> stat_byte_to_mega(display_channel->lz_stat.orig_size +
> display_channel->glz_stat.orig_size +
> + display_channel->off_stat.orig_size +
> display_channel->quic_stat.orig_size +
> display_channel->jpeg_stat.orig_size +
> display_channel->lz4_stat.orig_size +
> display_channel->jpeg_alpha_stat.orig_size),
> stat_byte_to_mega(display_channel->lz_stat.comp_size +
> glz_enc_size +
> + display_channel->off_stat.comp_size +
> display_channel->quic_stat.comp_size +
> display_channel->jpeg_stat.comp_size +
> display_channel->lz4_stat.comp_size +
> @@ -122,6 +132,7 @@ void display_channel_compress_stats_print(const
> DisplayChannel *display_channel)
> stat_cpu_time_to_sec(display_channel->lz_stat.total +
> display_channel->glz_stat.total +
> display_channel->zlib_glz_stat.total +
> + display_channel->off_stat.total +
> display_channel->quic_stat.total +
> display_channel->jpeg_stat.total +
> display_channel->lz4_stat.total +
> diff --git a/server/display-channel.h b/server/display-channel.h
> index 13b13b1..fc993e8 100644
> --- a/server/display-channel.h
> +++ b/server/display-channel.h
> @@ -213,6 +213,7 @@ struct DisplayChannel {
> uint64_t *add_to_cache_counter;
> uint64_t *non_cache_counter;
> #endif
> + stat_info_t off_stat;
> stat_info_t lz_stat;
> stat_info_t glz_stat;
> stat_info_t quic_stat;
Acked-by: Frediano Ziglio <fziglio at redhat.com>
Frediano
More information about the Spice-devel
mailing list