From: guangrong.xiao@gmail.com
To: pbonzini@redhat.com, mst@redhat.com, mtosatti@redhat.com
Cc: kvm@vger.kernel.org, Xiao Guangrong <xiaoguangrong@tencent.com>,
qemu-devel@nongnu.org, peterx@redhat.com, dgilbert@redhat.com,
wei.w.wang@intel.com, jiang.biao2@zte.com.cn
Subject: [PATCH v2 3/8] migration: show the statistics of compression
Date: Thu, 19 Jul 2018 20:15:15 +0800 [thread overview]
Message-ID: <20180719121520.30026-4-xiaoguangrong@tencent.com> (raw)
In-Reply-To: <20180719121520.30026-1-xiaoguangrong@tencent.com>
From: Xiao Guangrong <xiaoguangrong@tencent.com>
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 | 26 +++++++++++++++++++++++++-
5 files changed, 87 insertions(+), 1 deletion(-)
diff --git a/hmp.c b/hmp.c
index 47d36e3ccf..a9e2776d60 100644
--- a/hmp.c
+++ b/hmp.c
@@ -271,6 +271,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 0af75465b3..8fedf13889 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -754,6 +754,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 1b016e048d..e68b0e6dec 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -300,6 +300,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 */
@@ -337,6 +346,8 @@ struct PageSearchStatus {
};
typedef struct PageSearchStatus PageSearchStatus;
+CompressionStats compression_counters;
+
struct CompressParam {
bool done;
bool quit;
@@ -1597,6 +1608,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)
@@ -1872,6 +1901,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;
+ compression_counters.pages++;
ram_counters.transferred += len;
}
qemu_mutex_unlock(&comp_param[idx].mutex);
@@ -1903,6 +1935,10 @@ retry:
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;
}
@@ -2233,6 +2269,7 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss,
if (res > 0) {
return res;
}
+ compression_counters.busy++;
} else if (migrate_use_multifd()) {
return ram_save_multifd_page(rs, block, offset);
}
diff --git a/migration/ram.h b/migration/ram.h
index 457bf54b8c..a139066846 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 b4f394844b..5a34aa1754 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -75,6 +75,27 @@
'cache-miss': 'int', 'cache-miss-rate': 'number',
'overflow': 'int' } }
+##
+# @CompressionStats:
+#
+# Detailed migration compression statistics
+#
+# @pages: amount of pages compressed and transferred to the target VM
+#
+# @busy: count of times that no free thread was available to compress data
+#
+# @busy-rate: rate of thread busy
+#
+# @reduced-size: amount of bytes reduced by compression
+#
+# @compression-rate: rate of compressed size
+#
+# Since: 3.0
+##
+{ 'struct': 'CompressionStats',
+ 'data': {'pages': 'int', 'busy': 'int', 'busy-rate': 'number',
+ 'reduced-size': 'int', 'compression-rate': 'number' } }
+
##
# @MigrationStatus:
#
@@ -172,6 +193,8 @@
# only present when the postcopy-blocktime migration capability
# is enabled. (Since 3.0)
#
+# @compression: migration compression statistics, only returned if compression
+# feature is on and status is 'active' or 'completed' (Since 3.0)
#
# Since: 0.14.0
##
@@ -186,7 +209,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
next prev parent reply other threads:[~2018-07-19 12:15 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-19 12:15 [PATCH v2 0/8] migration: compression optimization guangrong.xiao
2018-07-19 12:15 ` [PATCH v2 1/8] migration: do not wait for free thread guangrong.xiao
2018-07-23 3:25 ` Peter Xu
2018-07-23 7:16 ` Xiao Guangrong
2018-07-23 18:36 ` Eric Blake
2018-07-24 7:40 ` Xiao Guangrong
2018-07-19 12:15 ` [PATCH v2 2/8] migration: fix counting normal page for compression guangrong.xiao
2018-07-23 3:33 ` Peter Xu
2018-07-19 12:15 ` guangrong.xiao [this message]
2018-07-23 4:36 ` [PATCH v2 3/8] migration: show the statistics of compression Peter Xu
2018-07-23 7:39 ` Xiao Guangrong
2018-07-23 8:05 ` Peter Xu
2018-07-23 8:40 ` Xiao Guangrong
2018-07-23 9:15 ` Peter Xu
2018-07-24 7:37 ` Xiao Guangrong
2018-07-25 16:44 ` Dr. David Alan Gilbert
2018-07-26 5:29 ` Peter Xu
2018-07-19 12:15 ` [PATCH v2 4/8] migration: introduce save_zero_page_to_file guangrong.xiao
2018-07-23 4:40 ` Peter Xu
2018-07-19 12:15 ` [PATCH v2 5/8] migration: drop the return value of do_compress_ram_page guangrong.xiao
2018-07-23 4:48 ` Peter Xu
2018-07-19 12:15 ` [PATCH v2 6/8] migration: move handle of zero page to the thread guangrong.xiao
2018-07-23 5:03 ` Peter Xu
2018-07-23 7:56 ` Xiao Guangrong
2018-07-23 8:28 ` Peter Xu
2018-07-23 8:44 ` Xiao Guangrong
2018-07-23 9:40 ` Peter Xu
2018-07-24 7:39 ` Xiao Guangrong
2018-07-19 12:15 ` [PATCH v2 7/8] migration: hold the lock only if it is really needed guangrong.xiao
2018-07-23 5:36 ` Peter Xu
2018-07-19 12:15 ` [PATCH v2 8/8] migration: do not flush_compressed_data at the end of each iteration guangrong.xiao
2018-07-23 5:49 ` Peter Xu
2018-07-23 8:05 ` Xiao Guangrong
2018-07-23 8:35 ` Peter Xu
2018-07-23 8:53 ` Xiao Guangrong
2018-07-23 9:01 ` Peter Xu
2018-07-24 7:29 ` Xiao Guangrong
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=20180719121520.30026-4-xiaoguangrong@tencent.com \
--to=guangrong.xiao@gmail.com \
--cc=dgilbert@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).