qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] cut large snapshot startup time (Vista runs in 5 secs)
@ 2008-05-19 10:18 Shahar Livne
  2008-06-02  1:59 ` andrzej zaborowski
  0 siblings, 1 reply; 3+ messages in thread
From: Shahar Livne @ 2008-05-19 10:18 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2527 bytes --]

This patch is a result of profiling research which I've done to shorten 
the startup time of a windows Vista snapshot on kvm, as part of 
http://support-matrix.com product.

The virtualization engine of SupportMatrix(tm) is based on kvm-35.
Background: The product starts for each network user (e.g. 30 users) a 
specific kvm/qemu snapshot based on details from the application 
database, and presents it on the user's browser using vnc java applet.

Everything played fine with less demanding guest OSs (like Windows XP / 
Windows 2000), but Vista which requires minimum 512MB took too long to 
start.
A customer's request to lower a the startup time of a vista snapshot 
from 10 seconds by at least 50% was the reason for the profiling effort.

It was found that loading the stored RAM within the qcow2 is responsible 
for a major part of the startup time. The function in vl.c, 
ram_load_static on snapshot loading (and ram_save_static on snapshot 
saving) run RAM/BDRV_HASH_BLOCK_SIZE times, which means that for 0.5GB 
RAM, and the default BDRV_HASH_BLOCK_SIZE=1k there are 500k calls of the 
ram_decompress_buf function (practically zlib decompression).
This is heavy, and it takes long time (around 9 seconds).
The patch uses a 16 times bigger buffer, and therefore reduces the 
amount of calls by 16 times (was found to be the best for my setup by 
trial and error). The time of the ram_load_static was reduced from 9 
seconds to around 4-5 seconds.
This change doesn't disturb also kvm (e.g. the video-addresses are still 
fully skipped within ram_load_static and ram_save_static).
Changing the compression (avoiding it or changing the default 
Z_DEFAULT_STRATEGY algorithm) did not improve the numbers.

Since I've seen that also in recent versions of qemu and kvm, the 
BDRV_HASH_BLOCK_SIZE is still 1k, I suggest the change. This change 
becomes more relevant when snapshots of guests with large amount of RAM 
are used.
I post it on qemu mailing list, since it is qemu issue and not kvm issue.

Details of the test setup:
Windows Vista was installed with 512MB.
Host OS is RedHat Enterprise 5.0
The server is Xeon E5310 1.60GHz, 8 cores, 16GB.
NO disk raids. Just simple IDE disk.
Final Vista snapshot startup time is around 5 seconds.

It is important to mention that old snapshots must be converted once 
this patch is applied.
Also, I would like to note that I've encountered no problems while 
working with the 16k based snapshots.
The patch was done against trunk r4497.

I'll be glad to get comments,
Shahar

[-- Attachment #2: snapshot_startup_time_cut.diff --]
[-- Type: text/x-patch, Size: 322 bytes --]

diff -Nuar qemu-4497/vl.c qemu-mod/vl.c
--- qemu-4497/vl.c	2008-05-19 12:26:46.000000000 +0300
+++ qemu-mod/vl.c	2008-05-19 12:30:51.000000000 +0300
@@ -6407,7 +6407,7 @@
     return 0;
 }
 
-#define BDRV_HASH_BLOCK_SIZE 1024
+#define BDRV_HASH_BLOCK_SIZE 16384
 #define IOBUF_SIZE 4096
 #define RAM_CBLOCK_MAGIC 0xfabe
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-06-08  8:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-19 10:18 [Qemu-devel] [PATCH] cut large snapshot startup time (Vista runs in 5 secs) Shahar Livne
2008-06-02  1:59 ` andrzej zaborowski
2008-06-08  8:10   ` Shahar Livne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).