mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-31 20:04:09 +00:00
compress-stat: Add not compressed image to statistics
To see how many images and data could not be compressed. Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
parent
1948566ce8
commit
af3aa4b1f4
32
server/dcc.c
32
server/dcc.c
@ -1192,29 +1192,35 @@ 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;
|
||||
}
|
||||
}
|
||||
goto lz_compress;
|
||||
@ -1222,16 +1228,24 @@ int dcc_compress_image(DisplayChannelClient *dcc,
|
||||
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
|
||||
lz_compress:
|
||||
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
|
||||
|
||||
@ -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 +
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user