From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org
Cc: amit.shah@redhat.com, armbru@redhat.com, qemu-block@nongnu.org,
quintela@redhat.com
Subject: [Qemu-devel] [RFC v2 4/4] Example use of rolling statistics in migration
Date: Wed, 4 Mar 2015 10:29:39 +0000 [thread overview]
Message-ID: <1425464979-20578-5-git-send-email-dgilbert@redhat.com> (raw)
In-Reply-To: <1425464979-20578-1-git-send-email-dgilbert@redhat.com>
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
This is an example use of the rolling statistics to
watch the 'expected downtime' in a bit more detail than
the current summary figure.
Example outputs from a simple run:
HMP:
expected downtime stats: Min/Max: 222, 1634 Mean: 983.8 (Weighted:
1005.1253) Count: 141 Values: 1248@39356292, 981@39356395, 774@39356497,
876@39356599, 1040@39356702
QMP:
"expected-downtime-stats": {
"min": 222,
"count": 378,
"mean": 1100.2,
"max": 1942,
"weighted-mean": 1115.710848,
"values": [
{
"tag": 39380740,
"value": 1118
},
{
"tag": 39380842,
"value": 953
},
{
"tag": 39380945,
"value": 1017
},
{
"tag": 39381048,
"value": 1336
},
{
"tag": 39381150,
"value": 1077
}
]
}
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
hmp.c | 5 ++++-
include/migration/migration.h | 1 +
migration/migration.c | 15 +++++++++++++++
qapi-schema.json | 6 +++++-
4 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/hmp.c b/hmp.c
index 20241d8..6bd19b2 100644
--- a/hmp.c
+++ b/hmp.c
@@ -138,7 +138,6 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
qapi_free_MouseInfoList(mice_list);
}
-__attribute__ (( unused )) /* Until later in patch series */
static void monitor_printf_RollingStats(Monitor *mon, const char *title,
RollingStats *r)
{
@@ -186,6 +185,10 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "expected downtime: %" PRIu64 " milliseconds\n",
info->expected_downtime);
}
+ if (info->has_expected_downtime_stats) {
+ monitor_printf_RollingStats(mon, "expected downtime stats",
+ info->expected_downtime_stats);
+ }
if (info->has_downtime) {
monitor_printf(mon, "downtime: %" PRIu64 " milliseconds\n",
info->downtime);
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 703b7d7..b37ec0c 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -63,6 +63,7 @@ struct MigrationState
int64_t xbzrle_cache_size;
int64_t setup_time;
int64_t dirty_sync_count;
+ RStats *expected_downtime_stats;
};
void process_incoming_migration(QEMUFile *f);
diff --git a/migration/migration.c b/migration/migration.c
index b3adbc6..4041823 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -24,6 +24,7 @@
#include "migration/block.h"
#include "qemu/thread.h"
#include "qmp-commands.h"
+#include "qemu/rolling-stats.h"
#include "trace.h"
enum {
@@ -201,6 +202,9 @@ MigrationInfo *qmp_query_migrate(Error **errp)
- s->total_time;
info->has_expected_downtime = true;
info->expected_downtime = s->expected_downtime;
+ info->expected_downtime_stats =
+ rstats_as_RollingStats(s->expected_downtime_stats);
+ info->has_expected_downtime_stats = true;
info->has_setup_time = true;
info->setup_time = s->setup_time;
@@ -238,6 +242,9 @@ MigrationInfo *qmp_query_migrate(Error **errp)
info->downtime = s->downtime;
info->has_setup_time = true;
info->setup_time = s->setup_time;
+ info->expected_downtime_stats =
+ rstats_as_RollingStats(s->expected_downtime_stats);
+ info->has_expected_downtime_stats = true;
info->has_ram = true;
info->ram = g_malloc0(sizeof(*info->ram));
@@ -389,12 +396,18 @@ static MigrationState *migrate_init(const MigrationParams *params)
memcpy(enabled_capabilities, s->enabled_capabilities,
sizeof(enabled_capabilities));
+ /* Resets the current state */
memset(s, 0, sizeof(*s));
s->params = *params;
memcpy(s->enabled_capabilities, enabled_capabilities,
sizeof(enabled_capabilities));
s->xbzrle_cache_size = xbzrle_cache_size;
+ if (!s->expected_downtime_stats) {
+ s->expected_downtime_stats = rstats_init(5, 0.2);
+ } else {
+ rstats_reset(s->expected_downtime_stats);
+ }
s->bandwidth_limit = bandwidth_limit;
s->state = MIG_STATE_SETUP;
trace_migrate_set_state(MIG_STATE_SETUP);
@@ -658,6 +671,8 @@ static void *migration_thread(void *opaque)
10000 is a small enough number for our purposes */
if (s->dirty_bytes_rate && transferred_bytes > 10000) {
s->expected_downtime = s->dirty_bytes_rate / bandwidth;
+ rstats_add_value(s->expected_downtime_stats,
+ s->expected_downtime, current_time);
}
qemu_file_reset_rate_limit(s->file);
diff --git a/qapi-schema.json b/qapi-schema.json
index 9f5cdce..c43f0e7 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -480,6 +480,9 @@
# may be expensive, but do not actually occur during the iterative
# migration rounds themselves. (since 1.6)
#
+# @expected-downtime-stats: #optional more detailed statistics from the
+# downtime estimation.
+#
# Since: 0.14.0
##
{ 'type': 'MigrationInfo',
@@ -489,7 +492,8 @@
'*total-time': 'int',
'*expected-downtime': 'int',
'*downtime': 'int',
- '*setup-time': 'int'} }
+ '*setup-time': 'int',
+ '*expected-downtime-stats': 'RollingStats' } }
##
# @query-migrate
--
2.1.0
prev parent reply other threads:[~2015-03-04 10:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-04 10:29 [Qemu-devel] [RFC v2 0/4] Rolling statistics utilities Dr. David Alan Gilbert (git)
2015-03-04 10:29 ` [Qemu-devel] [RFC v2 1/4] RollingStats qapi type Dr. David Alan Gilbert (git)
2015-03-04 10:29 ` [Qemu-devel] [RFC v2 2/4] Rolling statistics utilities Dr. David Alan Gilbert (git)
2015-03-04 10:29 ` [Qemu-devel] [RFC v2 3/4] hmp: Add a helper function for printing out a Rolling Statistics set Dr. David Alan Gilbert (git)
2015-03-04 10:29 ` Dr. David Alan Gilbert (git) [this message]
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=1425464979-20578-5-git-send-email-dgilbert@redhat.com \
--to=dgilbert@redhat.com \
--cc=amit.shah@redhat.com \
--cc=armbru@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.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).