From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: guangrong.xiao@gmail.com
Cc: kvm@vger.kernel.org, mst@redhat.com, mtosatti@redhat.com,
Xiao Guangrong <xiaoguangrong@tencent.com>,
qemu-devel@nongnu.org, peterx@redhat.com, wei.w.wang@intel.com,
jiang.biao2@zte.com.cn, pbonzini@redhat.com
Subject: Re: [PATCH 05/12] migration: show the statistics of compression
Date: Wed, 13 Jun 2018 17:25:08 +0100 [thread overview]
Message-ID: <20180613162508.GM2676@work-vm> (raw)
In-Reply-To: <20180604095520.8563-6-xiaoguangrong@tencent.com>
* guangrong.xiao@gmail.com (guangrong.xiao@gmail.com) wrote:
> From: Xiao Guangrong <xiaoguangrong@tencent.com>
>
> Then the uses can adjust the parameters based on this info
>
> Currently, it includes:
> pages: amount of pages compressed and transferred to the target VM
> busy: amount of count that no free thread to compress data
> busy-rate: rate of thread busy
> reduced-size: amount of bytes reduced by compression
> compression-rate: rate of compressed size
>
> Signed-off-by: Xiao Guangrong <xiaoguangrong@tencent.com>
> ---
> hmp.c | 13 +++++++++++++
> migration/migration.c | 11 +++++++++++
> migration/ram.c | 37 +++++++++++++++++++++++++++++++++++++
> migration/ram.h | 1 +
> qapi/migration.json | 25 ++++++++++++++++++++++++-
> 5 files changed, 86 insertions(+), 1 deletion(-)
>
> diff --git a/hmp.c b/hmp.c
> index ef93f4878b..5c2d3bd318 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -269,6 +269,19 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
> info->xbzrle_cache->overflow);
> }
>
> + if (info->has_compression) {
> + monitor_printf(mon, "compression pages: %" PRIu64 " pages\n",
> + info->compression->pages);
> + monitor_printf(mon, "compression busy: %" PRIu64 "\n",
> + info->compression->busy);
> + monitor_printf(mon, "compression busy rate: %0.2f\n",
> + info->compression->busy_rate);
> + monitor_printf(mon, "compression reduced size: %" PRIu64 "\n",
> + info->compression->reduced_size);
> + monitor_printf(mon, "compression rate: %0.2f\n",
> + info->compression->compression_rate);
> + }
> +
> if (info->has_cpu_throttle_percentage) {
> monitor_printf(mon, "cpu throttle percentage: %" PRIu64 "\n",
> info->cpu_throttle_percentage);
> diff --git a/migration/migration.c b/migration/migration.c
> index 05aec2c905..bf7c63a5a2 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -693,6 +693,17 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s)
> info->xbzrle_cache->overflow = xbzrle_counters.overflow;
> }
>
> + if (migrate_use_compression()) {
> + info->has_compression = true;
> + info->compression = g_malloc0(sizeof(*info->compression));
> + info->compression->pages = compression_counters.pages;
> + info->compression->busy = compression_counters.busy;
> + info->compression->busy_rate = compression_counters.busy_rate;
> + info->compression->reduced_size = compression_counters.reduced_size;
> + info->compression->compression_rate =
> + compression_counters.compression_rate;
> + }
> +
> if (cpu_throttle_active()) {
> info->has_cpu_throttle_percentage = true;
> info->cpu_throttle_percentage = cpu_throttle_get_percentage();
> diff --git a/migration/ram.c b/migration/ram.c
> index ee03b28435..80914b747e 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -292,6 +292,15 @@ struct RAMState {
> uint64_t num_dirty_pages_period;
> /* xbzrle misses since the beginning of the period */
> uint64_t xbzrle_cache_miss_prev;
> +
> + /* compression statistics since the beginning of the period */
> + /* amount of count that no free thread to compress data */
> + uint64_t compress_thread_busy_prev;
> + /* amount bytes reduced by compression */
> + uint64_t compress_reduced_size_prev;
> + /* amount of compressed pages */
> + uint64_t compress_pages_prev;
> +
> /* number of iterations at the beginning of period */
> uint64_t iterations_prev;
> /* Iterations since start */
> @@ -329,6 +338,8 @@ struct PageSearchStatus {
> };
> typedef struct PageSearchStatus PageSearchStatus;
>
> +CompressionStats compression_counters;
> +
> struct CompressParam {
> bool done;
> bool quit;
> @@ -1147,6 +1158,24 @@ static void migration_update_rates(RAMState *rs, int64_t end_time)
> rs->xbzrle_cache_miss_prev) / iter_count;
> rs->xbzrle_cache_miss_prev = xbzrle_counters.cache_miss;
> }
> +
> + if (migrate_use_compression()) {
> + uint64_t comp_pages;
> +
> + compression_counters.busy_rate = (double)(compression_counters.busy -
> + rs->compress_thread_busy_prev) / iter_count;
> + rs->compress_thread_busy_prev = compression_counters.busy;
> +
> + comp_pages = compression_counters.pages - rs->compress_pages_prev;
> + if (comp_pages) {
> + compression_counters.compression_rate =
> + (double)(compression_counters.reduced_size -
> + rs->compress_reduced_size_prev) /
> + (comp_pages * TARGET_PAGE_SIZE);
> + rs->compress_pages_prev = compression_counters.pages;
> + rs->compress_reduced_size_prev = compression_counters.reduced_size;
> + }
> + }
> }
>
> static void migration_bitmap_sync(RAMState *rs)
> @@ -1412,6 +1441,9 @@ static void flush_compressed_data(RAMState *rs)
> qemu_mutex_lock(&comp_param[idx].mutex);
> if (!comp_param[idx].quit) {
> len = qemu_put_qemu_file(rs->f, comp_param[idx].file);
> + /* 8 means a header with RAM_SAVE_FLAG_CONTINUE. */
> + compression_counters.reduced_size += TARGET_PAGE_SIZE - len + 8;
I think I'd rather save just len+8 rather than than the subtraction.
I think other than that, and Eric's comments, it's OK.
Dave
> + compression_counters.pages++;
> ram_counters.transferred += len;
> }
> qemu_mutex_unlock(&comp_param[idx].mutex);
> @@ -1441,6 +1473,10 @@ static int compress_page_with_multi_thread(RAMState *rs, RAMBlock *block,
> qemu_cond_signal(&comp_param[idx].cond);
> qemu_mutex_unlock(&comp_param[idx].mutex);
> pages = 1;
> + /* 8 means a header with RAM_SAVE_FLAG_CONTINUE. */
> + compression_counters.reduced_size += TARGET_PAGE_SIZE -
> + bytes_xmit + 8;
> + compression_counters.pages++;
> ram_counters.transferred += bytes_xmit;
> break;
> }
> @@ -1760,6 +1796,7 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss,
> if (res > 0) {
> return res;
> }
> + compression_counters.busy++;
> }
>
> return ram_save_page(rs, pss, last_stage);
> diff --git a/migration/ram.h b/migration/ram.h
> index d386f4d641..7b009b23e5 100644
> --- a/migration/ram.h
> +++ b/migration/ram.h
> @@ -36,6 +36,7 @@
>
> extern MigrationStats ram_counters;
> extern XBZRLECacheStats xbzrle_counters;
> +extern CompressionStats compression_counters;
>
> int xbzrle_cache_resize(int64_t new_size, Error **errp);
> uint64_t ram_bytes_remaining(void);
> diff --git a/qapi/migration.json b/qapi/migration.json
> index 3ec418dabf..a11987cdc4 100644
> --- a/qapi/migration.json
> +++ b/qapi/migration.json
> @@ -72,6 +72,26 @@
> 'cache-miss': 'int', 'cache-miss-rate': 'number',
> 'overflow': 'int' } }
>
> +##
> +# @CompressionStats:
> +#
> +# Detailed compression migration statistics
> +#
> +# @pages: amount of pages compressed and transferred to the target VM
> +#
> +# @busy: amount of count that no free thread to compress data
> +#
> +# @busy-rate: rate of thread busy
> +#
> +# @reduced-size: amount of bytes reduced by compression
> +#
> +# @compression-rate: rate of compressed size
> +#
> +##
> +{ 'struct': 'CompressionStats',
> + 'data': {'pages': 'int', 'busy': 'int', 'busy-rate': 'number',
> + 'reduced-size': 'int', 'compression-rate': 'number' } }
> +
> ##
> # @MigrationStatus:
> #
> @@ -169,6 +189,8 @@
> # only present when the postcopy-blocktime migration capability
> # is enabled. (Since 2.13)
> #
> +# @compression: compression migration statistics, only returned if compression
> +# feature is on and status is 'active' or 'completed' (Since 2.14)
> #
> # Since: 0.14.0
> ##
> @@ -183,7 +205,8 @@
> '*cpu-throttle-percentage': 'int',
> '*error-desc': 'str',
> '*postcopy-blocktime' : 'uint32',
> - '*postcopy-vcpu-blocktime': ['uint32']} }
> + '*postcopy-vcpu-blocktime': ['uint32'],
> + '*compression': 'CompressionStats'} }
>
> ##
> # @query-migrate:
> --
> 2.14.4
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2018-06-13 16:25 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-04 9:55 [PATCH 00/12] migration: improve multithreads for compression and decompression guangrong.xiao
2018-06-04 9:55 ` [PATCH 01/12] migration: do not wait if no free thread guangrong.xiao
2018-06-11 7:39 ` Peter Xu
2018-06-12 2:42 ` Xiao Guangrong
2018-06-12 3:15 ` Peter Xu
2018-06-13 15:43 ` Dr. David Alan Gilbert
2018-06-14 3:19 ` Xiao Guangrong
2018-06-04 9:55 ` [PATCH 02/12] migration: fix counting normal page for compression guangrong.xiao
2018-06-13 15:51 ` Dr. David Alan Gilbert
2018-06-14 3:32 ` Xiao Guangrong
2018-06-04 9:55 ` [PATCH 03/12] migration: fix counting xbzrle cache_miss_rate guangrong.xiao
2018-06-13 16:09 ` Dr. David Alan Gilbert
2018-06-15 11:30 ` Dr. David Alan Gilbert
2018-06-04 9:55 ` [PATCH 04/12] migration: introduce migration_update_rates guangrong.xiao
2018-06-13 16:17 ` Dr. David Alan Gilbert
2018-06-14 3:35 ` Xiao Guangrong
2018-06-15 11:32 ` Dr. David Alan Gilbert
2018-06-04 9:55 ` [PATCH 05/12] migration: show the statistics of compression guangrong.xiao
2018-06-04 22:31 ` Eric Blake
2018-06-06 12:44 ` Xiao Guangrong
2018-06-13 16:25 ` Dr. David Alan Gilbert [this message]
2018-06-14 6:48 ` Xiao Guangrong
2018-07-16 19:01 ` Dr. David Alan Gilbert
2018-07-18 8:51 ` Xiao Guangrong
2018-06-04 9:55 ` [PATCH 06/12] migration: do not detect zero page for compression guangrong.xiao
2018-06-19 7:30 ` Peter Xu
2018-06-28 9:12 ` Xiao Guangrong
2018-06-28 9:36 ` Daniel P. Berrangé
2018-06-29 3:50 ` Xiao Guangrong
2018-06-29 9:54 ` Dr. David Alan Gilbert
2018-06-29 9:42 ` Dr. David Alan Gilbert
2018-07-03 3:53 ` Xiao Guangrong
2018-07-16 18:58 ` Dr. David Alan Gilbert
2018-07-18 8:46 ` Xiao Guangrong
2018-07-22 16:05 ` Michael S. Tsirkin
2018-07-23 7:12 ` Xiao Guangrong
2018-06-04 9:55 ` [PATCH 07/12] migration: hold the lock only if it is really needed guangrong.xiao
2018-06-19 7:36 ` Peter Xu
2018-06-28 9:33 ` Xiao Guangrong
2018-06-29 11:22 ` Dr. David Alan Gilbert
2018-07-03 6:27 ` Xiao Guangrong
2018-07-11 8:21 ` Peter Xu
2018-07-12 7:47 ` Xiao Guangrong
2018-07-12 8:26 ` Peter Xu
2018-07-18 8:56 ` Xiao Guangrong
2018-07-18 10:18 ` Peter Xu
2018-07-13 17:44 ` Dr. David Alan Gilbert
2018-06-04 9:55 ` [PATCH 08/12] migration: do not flush_compressed_data at the end of each iteration guangrong.xiao
2018-07-13 18:01 ` Dr. David Alan Gilbert
2018-07-18 8:44 ` Xiao Guangrong
2018-06-04 9:55 ` [PATCH 09/12] ring: introduce lockless ring buffer guangrong.xiao
2018-06-20 4:52 ` Peter Xu
2018-06-28 10:02 ` Xiao Guangrong
2018-06-28 11:55 ` Wei Wang
2018-06-29 3:55 ` Xiao Guangrong
2018-07-03 15:55 ` Paul E. McKenney
2018-06-20 5:55 ` Peter Xu
2018-06-28 14:00 ` Xiao Guangrong
2018-06-20 12:38 ` Michael S. Tsirkin
2018-06-29 7:30 ` Xiao Guangrong
2018-06-29 13:08 ` Michael S. Tsirkin
2018-07-03 7:31 ` Xiao Guangrong
2018-06-28 13:36 ` Jason Wang
2018-06-29 3:59 ` Xiao Guangrong
2018-06-29 6:15 ` Jason Wang
2018-06-29 7:47 ` Xiao Guangrong
2018-06-29 4:23 ` Michael S. Tsirkin
2018-06-29 7:44 ` Xiao Guangrong
2018-06-04 9:55 ` [PATCH 10/12] migration: introduce lockless multithreads model guangrong.xiao
2018-06-20 6:52 ` Peter Xu
2018-06-28 14:25 ` Xiao Guangrong
2018-07-13 16:24 ` Dr. David Alan Gilbert
2018-07-18 7:12 ` Xiao Guangrong
2018-06-04 9:55 ` [PATCH 11/12] migration: use lockless Multithread model for compression guangrong.xiao
2018-06-04 9:55 ` [PATCH 12/12] migration: use lockless Multithread model for decompression guangrong.xiao
2018-06-11 8:00 ` [PATCH 00/12] migration: improve multithreads for compression and decompression Peter Xu
2018-06-12 3:19 ` Xiao Guangrong
2018-06-12 5:36 ` Peter Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180613162508.GM2676@work-vm \
--to=dgilbert@redhat.com \
--cc=guangrong.xiao@gmail.com \
--cc=jiang.biao2@zte.com.cn \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=wei.w.wang@intel.com \
--cc=xiaoguangrong@tencent.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.