On 01.06.21 18:10, Olaf Hering wrote:
Show how fast domU pages are transferred in each iteration.The relevant data is how fast the pfns travel, not so much how much protocol overhead exists. So the reported MiB/sec is just for pfns. Signed-off-by: Olaf Hering <o...@aepfle.de> --- tools/libs/saverestore/common.h | 2 ++ tools/libs/saverestore/save.c | 47 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/tools/libs/saverestore/common.h b/tools/libs/saverestore/common.h index 50a8479d39..f5fe23caad 100644 --- a/tools/libs/saverestore/common.h +++ b/tools/libs/saverestore/common.h @@ -250,6 +250,8 @@ struct xc_sr_context bool debug;unsigned long p2m_size;+ size_t pages_sent; + size_t overhead_sent;struct precopy_stats stats; diff --git a/tools/libs/saverestore/save.c b/tools/libs/saverestore/save.cindex bcff2d28f5..760ca04a84 100644 --- a/tools/libs/saverestore/save.c +++ b/tools/libs/saverestore/save.c @@ -1,5 +1,6 @@ #include <assert.h> #include <arpa/inet.h> +#include <time.h>#include "common.h" @@ -238,6 +239,8 @@ static int write_batch(struct xc_sr_context *ctx)iov[3].iov_len = nr_pfns * sizeof(*rec_pfns);iovcnt = 4;+ ctx->save.pages_sent += nr_pages;+ ctx->save.overhead_sent += sizeof(rec) + sizeof(hdr) + nr_pfns *
sizeof(*rec_pfns);
if ( nr_pages ){ @@ -357,6 +360,43 @@ static int suspend_domain(struct xc_sr_context *ctx) return 0; }+static void show_transfer_rate(struct xc_sr_context *ctx, struct timespec *start)+{ + xc_interface *xch = ctx->xch; + struct timespec end = {}, diff = {}; + size_t ms, MiB_sec = ctx->save.pages_sent * PAGE_SIZE;
I'd rather not initialize MiB_sec here ...
+ + if (!MiB_sec)
... and test for ctx->save.pages_sent to be non-zero here.
+ return; + + if ( clock_gettime(CLOCK_MONOTONIC, &end) ) + PERROR("clock_gettime"); + + if ( (end.tv_nsec - start->tv_nsec) < 0 ) + { + diff.tv_sec = end.tv_sec - start->tv_sec - 1; + diff.tv_nsec = end.tv_nsec - start->tv_nsec + (1000U*1000U*1000U); + } + else + { + diff.tv_sec = end.tv_sec - start->tv_sec; + diff.tv_nsec = end.tv_nsec - start->tv_nsec; + } + + ms = (diff.tv_nsec / (1000U*1000U)); + if (!ms) + ms = 1;
I'd move this ...
+ ms += (diff.tv_sec * 1000U);
... below this.
+ + MiB_sec *= 1000U; + MiB_sec /= ms; + MiB_sec /= 1024U*1024U;
Avoid MiB_sec holding bytes per second for some time and use: MiB_sec = ((ctx->save.pages_sent * PAGE_SIZE * 1000) / ms) / (1024U * 1024U); Juergen
OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key
OpenPGP_signature
Description: OpenPGP digital signature