KVM performance
Hi,
I did some testing of KVM on my woodcrest machine. And I found that building a 2.6.19 kernel with identical configuration takes 845 sec on a guest and 210 sec on the host. So the compile is about 4X slower on the guest :(
The guest ran with 2.6.19 kernel and host ran with a 2.6.20-rc5 kernel. The guest file image is created with raw format. Wonder if people see similar performance figure?
Tim
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Hey,
Quoted 6 lines
Hi,
I did some testing of KVM on my woodcrest machine. And I found that building a 2.6.19 kernel with identical configuration takes 845 sec on a guest and 210 sec on the host. So the compile is about 4X slower on the guest :(
I wasn't able to compile some vanilla kernels, but i did two loops on the host and guest.
First, with nearly no hd read/writes.
# time (for I in $(seq 1 100000) ; do echo $I > /dev/null ; done) host: 3.7s 100% guest: 4.1s 110%
And a second one with hd read/writes (might have a look at strace of date, tells you that date open/closes a lot of files):
# time (for I in $(seq 1 1000) ; do date > /dev/null ; done) host: 1s 100% guest: 14s 1400%
i don't really know how much those tests say, but:
It seems as if the hd access is the bottleneck :)
fabian
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Quoted 12 lines · Tim Chen
Hi,
I did some testing of KVM on my woodcrest machine. And I found that building a 2.6.19 kernel with identical configuration takes 845 sec on a guest and 210 sec on the host. So the compile is about 4X slower on the guest :(
The guest ran with 2.6.19 kernel and host ran with a 2.6.20-rc5 kernel. The guest file image is created with raw format. Wonder if people see similar performance figure?
http://virt.kernelnewbies.org/KVM/Performance cites a 2.5X difference, but for a different cpu.
It's probably better to use an lvm volume rather than a raw file, and to give the guest ample memory. In addition, quite a few performance optimizations are missing from kvm:
- after modifying a pte, kvm doesn't preload the modified pte into shadow, but instead lets the guest fault it in
- disk access is blocking instead of non-blocking. this will be fixed by merging qemu-cvs, which uses aio for disk access.
- better heuristics for recycling page tables are needed
- prefaulting for common access patterns can help
- kvm currently saves the entire fpu state on every exit, even if it has not been modified
Signature · 8 lines
Do not meddle in the internals of kernels, for they are subtle and quick to panic. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Quoted 1 line · Avi Kivity
In addition, quite a few performance optimizations are missing from kvm:
Hi Avi!
Just thought I'd share my experience with some of these optimizations
in lguest. I use virtbench (http://ozlabs.org/~rusty/virtbench) to try to measure optimization results; it still needs more tests (and an explicit kvm backend).
Quoted 2 lines
- after modifying a pte, kvm doesn't preload the modified pte into shadow, but instead lets the guest fault it in
lguest doesn't either, but don't you still want the fault to update the host accessed bit?
Quoted 2 lines
- disk access is blocking instead of non-blocking. this will be fixed by merging qemu-cvs, which uses aio for disk access.
Do you plan on multiple guest I/Os outstanding, too? I would think that I/O scheduling in the guest could be more effective than I/O scheduling in the host if there is more than one guest sharing a host device. It could potentially reduce guest<->host transitions too.
Quoted 1 line
- better heuristics for recycling page tables are needed
Definitely a whole area of research here...
Quoted 1 line
- prefaulting for common access patterns can help
Hmm, interesting idea. Any specific thoughts?
Quoted 2 lines
- kvm currently saves the entire fpu state on every exit, even if it has not been modified
This was measurable for lguest, but our transition is slow so your % improvement might be greater. With intelligent TS (2.13GHz Core Duo2):
Time for one context switch via pipe: 53514 nsec
Time for one Copy-on-Write fault: 14841 nsec
Time to exec client once: 1155102 nsec
Time for one fork/exit/wait: 764490 nsec
Time for two PTE updates: 23800 nsec
Removing it and restoring FPU every time:
Time for one context switch via pipe: 56229 nsec
Time for one Copy-on-Write fault: 15989 nsec
Time to exec client once: 1243624 nsec
Time for one fork/exit/wait: 824647 nsec
Time for two PTE updates: 25056 nsec
Cheers!
Rusty.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Quoted 5 lines · Rusty Russell
Quoted 2 lines · Avi Kivity
In addition, quite a few performance optimizations are missing from kvm:
Quoted 7 lines
Hi Avi!
Just thought I'd share my experience with some of these optimizations
in lguest. I use virtbench (http://ozlabs.org/~rusty/virtbench) to try to measure optimization results; it still needs more tests (and an explicit kvm backend).
A kvm backend would be appreciated.
Quoted 8 lines
Quoted 4 lines
- after modifying a pte, kvm doesn't preload the modified pte into shadow, but instead lets the guest fault it in
lguest doesn't either, but don't you still want the fault to update the host accessed bit?
The story here is that the guest is handling a pagefault and writing the new guest pte. kvm traps the write (guest pagetables are write protected), and has the option of updating the shadow pte to reflect the guest pte.
The clever guest kernel will set the accessed bit (and the dirty bit on writable ptes) to avoid an rmw cycle by the hardware pagetable walker.
[two instrumented runs later]
Both Linux and Windows seem to do this optimization.
Quoted 10 lines
Quoted 4 lines
- disk access is blocking instead of non-blocking. this will be fixed by merging qemu-cvs, which uses aio for disk access.
Do you plan on multiple guest I/Os outstanding, too? I would think that I/O scheduling in the guest could be more effective than I/O scheduling in the host if there is more than one guest sharing a host device. It could potentially reduce guest<->host transitions too.
qemu-cvs has scsi emulation IIRC, which allows multiple outstanding requests. But the big improvement comes from allowing even one outstanding request (current kvm will block the cpu as soon as a disk request is issued).
Quoted 6 lines
Quoted 2 lines
- prefaulting for common access patterns can help
Hmm, interesting idea. Any specific thoughts?
Linear :)
Also, if we see a lot of host faults in a pagetable, but no guest faults, we can assume that we're rebuilding a recycled shadow page, and fault the entire page in at once.
Quoted 13 lines
Quoted 3 lines
- kvm currently saves the entire fpu state on every exit, even if it has not been modified
This was measurable for lguest, but our transition is slow so your % improvement might be greater. With intelligent TS (2.13GHz Core Duo2):
Time for one context switch via pipe: 53514 nsec
Time for one Copy-on-Write fault: 14841 nsec
Time to exec client once: 1155102 nsec
Time for one fork/exit/wait: 764490 nsec
Time for two PTE updates: 23800 nsec
Quoted 8 lines
Removing it and restoring FPU every time:
Time for one context switch via pipe: 56229 nsec
Time for one Copy-on-Write fault: 15989 nsec
Time to exec client once: 1243624 nsec
Time for one fork/exit/wait: 824647 nsec
Time for two PTE updates: 25056 nsec
Good, I hope it's worthwhile for kvm too.
Signature · 8 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Quoted 6 lines · Avi Kivity
Rusty Russell wrote:
I use virtbench (http://ozlabs.org/~rusty/virtbench) to tryQuoted 2 lines
to measure optimization results; it still needs more tests (and an explicit kvm backend).
A kvm backend would be appreciated.
Yes, and patches are most welcome 8) Actually, I'll work on this week.
Quoted 10 lines
Quoted 4 lines
Quoted 2 lines
- after modifying a pte, kvm doesn't preload the modified pte into shadow, but instead lets the guest fault it in
lguest doesn't either, but don't you still want the fault to update the host accessed bit?
The story here is that the guest is handling a pagefault and writing the new guest pte. kvm traps the write (guest pagetables are write protected), and has the option of updating the shadow pte to reflect the guest pte.
Quoted 6 lines
The clever guest kernel will set the accessed bit (and the dirty bit on writable ptes) to avoid an rmw cycle by the hardware pagetable walker.
[two instrumented runs later]
Both Linux and Windows seem to do this optimization.
Right. This (trivial!) optimization wins lguest a good 10%:
Before:
Time for one Copy-on-Write fault: 13622 nsec
Time to exec client once: 1085481 nsec
Time for one fork/exit/wait: 700796 nsec
After:
Time for one Copy-on-Write fault: 12036 nsec
Time to exec client once: 969899 nsec
Time for one fork/exit/wait: 664601 nsec
Thanks!
Rusty.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Quoted 10 lines · Rusty Russell
Quoted 7 lines
The clever guest kernel will set the accessed bit (and the dirty bit on writable ptes) to avoid an rmw cycle by the hardware pagetable walker.
[two instrumented runs later]
Both Linux and Windows seem to do this optimization.
Right. This (trivial!) optimization wins lguest a good 10%:
Quoted 10 lines
Before:
Time for one Copy-on-Write fault: 13622 nsec
Time to exec client once: 1085481 nsec
Time for one fork/exit/wait: 700796 nsec
After:
Time for one Copy-on-Write fault: 12036 nsec
Time to exec client once: 969899 nsec
Time for one fork/exit/wait: 664601 nsec
Another optimization is that we can stop having two parallel implementations of the same code. I suggest we start thinking how to merge.
Signature · 8 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Quoted 5 lines · Rusty Russell
Quoted 3 lines · Avi Kivity
Rusty Russell wrote:
I use virtbench (http://ozlabs.org/~rusty/virtbench) to try
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
to measure optimization results; it still needs more tests (and an explicit kvm backend).
A kvm backend would be appreciated.
Yes, and patches are most welcome 8) Actually, I'll work on this week.
Attached patch was my initial attempt. I wanted it to work with mostly unmodified guest images so the only requirement is that a getty is spawned on ttyS0. I ran in to quite a few problems with virtbench though once I started launching multiple guests and haven't gotten around to debugging those yet.
Regards,
Anthony Liguori
Quoted 32 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
- after modifying a pte, kvm doesn't preload the modified pte into shadow, but instead lets the guest fault it in
lguest doesn't either, but don't you still want the fault to update the host accessed bit?
Quoted 8 lines
The story here is that the guest is handling a pagefault and writing the new guest pte. kvm traps the write (guest pagetables are write protected), and has the option of updating the shadow pte to reflect the guest pte.
The clever guest kernel will set the accessed bit (and the dirty bit on writable ptes) to avoid an rmw cycle by the hardware pagetable walker.
[two instrumented runs later]
Both Linux and Windows seem to do this optimization.
Right. This (trivial!) optimization wins lguest a good 10%:
Before:
Time for one Copy-on-Write fault: 13622 nsec
Time to exec client once: 1085481 nsec
Time for one fork/exit/wait: 700796 nsec
After:
Time for one Copy-on-Write fault: 12036 nsec
Time to exec client once: 969899 nsec
Time for one fork/exit/wait: 664601 nsecThanks!
Rusty.
Quoted 10 lines
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
kvm/SETTINGS new file +3 -0
@@ -0,0 +1,3 @@ +# Sources from all scripts +ROOT_FILE="/mnt/FC-5-i386.img" +QEMU=qemu
kvm/serial.py new file +58 -0
58 lines not on this page · raw message
kvm/start new file +13 -0
@@ -0,0 +1,13 @@ +#! /bin/sh + +set -e + +. kvm/SETTINGS + +#if grep AuthenticAMD 2>/dev/null ; then +# modules="kvm kvm-amd" +#else +# modules="kvm kvm-intel" +#fi + +#[ -c /dev/kvm ] || modprobe $modules
kvm/start_machine new file +10 -0
@@ -0,0 +1,10 @@ +#! /bin/sh + +. kvm/SETTINGS + +serial_port=$((1025 + $1)) + +$QEMU -m 128 -hda "${ROOT_FILE}" -snapshot -serial tcp:localhost:${serial_port},server,nowait -kernel-kqemu & +sleep 2 +python kvm/serial.py 127.0.0.1 ${serial_port} root ibm4xen virtclient $1 $2 $3 & +jobs -p %1
kvm/stop new file +4 -0
@@ -0,0 +1,4 @@ +#! /bin/sh + +. kvm/SETTINGS +exit 0
kvm/stop_machine new file +5 -0
@@ -0,0 +1,5 @@ +#! /bin/sh + +. kvm/SETTINGS + +kill $1
server.c +1 -1
@@ -227,7 +227,7 @@ static struct sockaddr_in get_server_addsocklen_t socklen =sizeof (saddr);/* This assumes we have an eth0. */ -strcpy (ifr.ifr_name,"eth0" ); +strcpy (ifr.ifr_name,"ath0" ); sin->sin_family =AF_INET ;if (ioctl (sock,SIOCGIFADDR , &ifr) !=0 )err (1 ,"Getting interface address for eth0" );
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
Quoted 2 lines · Avi Kivity
Another optimization is that we can stop having two parallel implementations of the same code. I suggest we start thinking how to merge.
KVM has more ambition than lguest, so I was planning on letting you do all the hard work then rebase my code on top once the mmu branch hits mainline 8) I've grabbed the release SVN tree and will look through it to see how it'll fit...
(lguest's page_table.c is only 450 lines, BUT I doubt it would stay that way if I implemented a decent one 8)
Cheers,
Rusty.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV