Re: [RFC kvm-unit-tests] api: Add dirty logging performance test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux