From: Avi Kivity <avi@redhat.com>
To: Takuya Yoshikawa <takuya.yoshikawa@gmail.com>
Cc: mtosatti@redhat.com, kvm@vger.kernel.org
Subject: Re: [RFC kvm-unit-tests] api: Add dirty logging performance test
Date: Sun, 08 Jan 2012 16:21:08 +0200 [thread overview]
Message-ID: <4F09A654.6020408@redhat.com> (raw)
In-Reply-To: <20120108225852.7c51724ce86f312b8e6b36f9@gmail.com>
On 01/08/2012 03:58 PM, Takuya Yoshikawa wrote:
> Check how long it takes to get dirty log according to the number of
> dirty pages, like:
>
> get dirty log: 49 us for 1 dirty pages
> get dirty log: 49 us for 2 dirty pages
> get dirty log: 45 us for 4 dirty pages
> get dirty log: 41 us for 8 dirty pages
> get dirty log: 40 us for 16 dirty pages
> get dirty log: 44 us for 32 dirty pages
> get dirty log: 39 us for 64 dirty pages
> get dirty log: 42 us for 128 dirty pages
> get dirty log: 45 us for 256 dirty pages
> get dirty log: 53 us for 512 dirty pages
> get dirty log: 72 us for 1024 dirty pages
> get dirty log: 99 us for 2048 dirty pages
> get dirty log: 132 us for 4096 dirty pages
> get dirty log: 224 us for 8192 dirty pages
> get dirty log: 383 us for 16384 dirty pages
> get dirty log: 725 us for 32768 dirty pages
> get dirty log: 1412 us for 65536 dirty pages
> get dirty log: 2746 us for 131072 dirty pages
> get dirty log: 5455 us for 262144 dirty pages
Nice!
> +
> +void write_mem(volatile bool& running, volatile int& nr_dirty_pages,
> + void* logged_slot_virt)
> +{
> + while (nr_dirty_pages >= 0) {
> + char* var = static_cast<char*>(logged_slot_virt);
> +
> + while (!running) {
> + delay_loop(1000);
> + }
> + for (int i = 0; i < nr_dirty_pages; ++i) {
> + ++(*var);
> + var += page_size;
> + }
> + running = false;
You use running both to start this loop, and signal its end. Better to
use two variables.
But why use threads at all? Just call this before reading the dirty
log, no need for synchronization.
> + }
> +}
> +
> +void check_dirty_log(mem_slot& slot,
> + volatile bool& running,
> + volatile int& nr_dirty_pages)
> +{
> + slot.set_dirty_logging(true);
> + slot.update_dirty_log();
> +
> + for (int i = 1; i <= nr_pages; i *= 2) {
> + struct timeval start_time, end_time;
> + long time_usec;
> +
> + nr_dirty_pages = i;
> + running = true;
> + // wait until the guest finishes writing
> + while (running) {
> + delay_loop(1000);
> + }
> +
> + gettimeofday(&start_time, NULL);
> + slot.update_dirty_log();
> + gettimeofday(&end_time, NULL);
Nicer to have a function that returns time in nanoseconds.
> +
> + time_usec = 1000 * 1000 * (end_time.tv_sec - start_time.tv_sec);
> + time_usec += end_time.tv_usec - start_time.tv_usec;
> + printf("get dirty log: %6ld us for %10d dirty pages\n",
> + time_usec, nr_dirty_pages);
> + }
> +
> + // stop the guest
> + nr_dirty_pages = -1;
> + running = true;
> + slot.set_dirty_logging(false);
> +}
> +
> +}
> +
>
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2012-01-08 14:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-08 13:58 [RFC kvm-unit-tests] api: Add dirty logging performance test Takuya Yoshikawa
2012-01-08 14:21 ` Avi Kivity [this message]
2012-01-08 14:49 ` Takuya Yoshikawa
2012-01-08 14:54 ` Avi Kivity
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=4F09A654.6020408@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=takuya.yoshikawa@gmail.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.