mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-25 11:04:35 +00:00
Added option to display dump/restore stats
Currently criu writes dump/restore statistics to a file. This patch adds the option '--display-stats' which additionally displays the same information on the console: # criu dump --display-stats -D /tmp/cp -t <PID> Displaying dump stats: Freezing time: 133 us Frozen time: 135173 us Memory dump time: 114760 us Memory write time: 85107 us IRMAP resolve time: 0 us Memory pages scanned: 2099 (0x833) Memory pages skipped from parent: 0 (0x0) Memory pages written: 1052 (0x41c) # criu restore --display-stats -D /tmp/cp Displaying restore stats: Pages compared: 0 (0x0) Pages skipped COW: 0 (0x0) Pages restored: 51227 (0xc81b) Restore time: 57428 us Forking time: 51473 us v2: - fix compile failure on 32bit ARM travis-ci: success for Added option to display dump/restore stats (rev2) Signed-off-by: Adrian Reber <areber@redhat.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
parent
310bcbc90e
commit
feddef44a1
3 changed files with 42 additions and 0 deletions
|
|
@ -282,6 +282,7 @@ int main(int argc, char *argv[], char *envp[])
|
|||
{ "cgroup-dump-controller", required_argument, 0, 1082 },
|
||||
{ SK_INFLIGHT_PARAM, no_argument, 0, 1083 },
|
||||
{ "deprecated", no_argument, 0, 1084 },
|
||||
{ "display-stats", no_argument, 0, 1086 },
|
||||
{ },
|
||||
};
|
||||
|
||||
|
|
@ -594,6 +595,9 @@ int main(int argc, char *argv[], char *envp[])
|
|||
pr_msg("Turn deprecated stuff ON\n");
|
||||
opts.deprecated_ok = true;
|
||||
break;
|
||||
case 1086:
|
||||
opts.display_stats = true;
|
||||
break;
|
||||
case 'V':
|
||||
pr_msg("Version: %s\n", CRIU_VERSION);
|
||||
if (strcmp(CRIU_GITID, "0"))
|
||||
|
|
@ -913,6 +917,7 @@ usage:
|
|||
" -v2|-vv - also warnings (default level)\n"
|
||||
" -v3|-vvv - also information messages and timestamps\n"
|
||||
" -v4|-vvvv - lots of debug\n"
|
||||
" --display-stats print out dump/restore stats\n"
|
||||
"\n"
|
||||
"* Memory dumping options:\n"
|
||||
" --track-mem turn on memory changes tracker in kernel\n"
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ struct cr_options {
|
|||
* to turn one ON while the code is in.
|
||||
*/
|
||||
bool deprecated_ok;
|
||||
bool display_stats;
|
||||
};
|
||||
|
||||
extern struct cr_options opts;
|
||||
|
|
|
|||
36
criu/stats.c
36
criu/stats.c
|
|
@ -3,6 +3,7 @@
|
|||
#include <sys/time.h>
|
||||
#include "int.h"
|
||||
#include "atomic.h"
|
||||
#include "cr_options.h"
|
||||
#include "rst-malloc.h"
|
||||
#include "protobuf.h"
|
||||
#include "stats.h"
|
||||
|
|
@ -102,6 +103,38 @@ static void encode_time(int t, u_int32_t *to)
|
|||
*to = tm->total.tv_sec * USEC_PER_SEC + tm->total.tv_usec;
|
||||
}
|
||||
|
||||
static void display_stats(int what, StatsEntry *stats)
|
||||
{
|
||||
if (what == DUMP_STATS) {
|
||||
pr_msg("Displaying dump stats:\n");
|
||||
pr_msg("Freezing time: %d us\n", stats->dump->freezing_time);
|
||||
pr_msg("Frozen time: %d us\n", stats->dump->frozen_time);
|
||||
pr_msg("Memory dump time: %d us\n", stats->dump->memdump_time);
|
||||
pr_msg("Memory write time: %d us\n", stats->dump->memwrite_time);
|
||||
if (stats->dump->has_irmap_resolve)
|
||||
pr_msg("IRMAP resolve time: %d us\n", stats->dump->irmap_resolve);
|
||||
pr_msg("Memory pages scanned: %" PRIu64 " (0x%" PRIx64 ")\n", stats->dump->pages_scanned,
|
||||
stats->dump->pages_scanned);
|
||||
pr_msg("Memory pages skipped from parent: %" PRIu64 " (0x%" PRIx64 ")\n",
|
||||
stats->dump->pages_skipped_parent,
|
||||
stats->dump->pages_skipped_parent);
|
||||
pr_msg("Memory pages written: %" PRIu64 " (0x%" PRIx64 ")\n", stats->dump->pages_written,
|
||||
stats->dump->pages_written);
|
||||
} else if (what == RESTORE_STATS) {
|
||||
pr_msg("Displaying restore stats:\n");
|
||||
pr_msg("Pages compared: %" PRIu64 " (0x%" PRIx64 ")\n", stats->restore->pages_compared,
|
||||
stats->restore->pages_compared);
|
||||
pr_msg("Pages skipped COW: %" PRIu64 " (0x%" PRIx64 ")\n", stats->restore->pages_skipped_cow,
|
||||
stats->restore->pages_skipped_cow);
|
||||
if (stats->restore->has_pages_restored)
|
||||
pr_msg("Pages restored: %" PRIu64 " (0x%" PRIx64 ")\n", stats->restore->pages_restored,
|
||||
stats->restore->pages_restored);
|
||||
pr_msg("Restore time: %d us\n", stats->restore->restore_time);
|
||||
pr_msg("Forking time: %d us\n", stats->restore->forking_time);
|
||||
} else
|
||||
return;
|
||||
}
|
||||
|
||||
void write_stats(int what)
|
||||
{
|
||||
StatsEntry stats = STATS_ENTRY__INIT;
|
||||
|
|
@ -146,6 +179,9 @@ void write_stats(int what)
|
|||
pb_write_one(img, &stats, PB_STATS);
|
||||
close_image(img);
|
||||
}
|
||||
|
||||
if (opts.display_stats)
|
||||
display_stats(what, &stats);
|
||||
}
|
||||
|
||||
int init_stats(int what)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue