A Simple CPU and Memory Performance Test of Xen Dom0 and DomU
Posted on In VirtualizationPlease refer to Setting Up Xen Dom0 on Fedora : Xen 3.4.1 with Linux Kernel 2.6.29 on Fedora 12 for the platform of this test (this test runs on Fedora 11, however).
I have done some simple performance test on DomU and Dom0 and compare with the performance on physical machines. These test are simple, but it can provides some performance factor of xen. I test the CPU bound, memory write and memory read performance of Dom0, DomU and compare them with the result of the test on physical machine. Each test are done for 50 times and the the Average (E), Standard deviation (SD) and SD/E are calculated.
Test method:
I only past the C code here because I think it is clear enough.
1) CPU bound:
The code:
const int test_limit = 100000; cout << "-----------------------------" << endl; cout << "cpu bound test begins." << endl; clock_t begin_time = clock(); register int a = 0; for (register int i = 0; i < test_limit; i++) { for (register int j = 0; j < test_limit; j++) { a += i + j; } } clock_t end_time = clock(); do_nothing(a); int time = (end_time - begin_time) / (CLOCKS_PER_SEC / 1000);
2) Memory read:
The code:
const int test_times = 1000000; const int data_size = 1000000000; const int data_interval = 1000000; int* array_read = new int[data_size]; cout << "----------------------" << endl << "Memory read bound test begins." << endl; register int read_value = 0; long read_begin =0; long read_end = 0; int data_range = data_size - test_times; read_begin = clock(); for (register int t = 0; t < test_times; t++) { for (register int i = 0; i < data_range; i += data_interval) { read_value = array_read[i + t]; } } read_end = clock(); do_nothing(read_value); int time = (read_end - read_begin) / (CLOCKS_PER_SEC / 1000);
3) Memory write:
The code:
const int test_times = 1000000; const int data_size = 1000000000; const int data_interval = 1000000; int* array_write = new int[data_size]; cout << "----------------------" << endl << "Memory write bound test begins." << endl; long write_begin = 0; long write_end = 0; int data_range = data_size - test_times; write_begin = clock(); for (register int t = 0; t < test_times; t++) { for (register int i = 0; i < data_range; i += data_interval) { array_write[i + t] = 528283; } } write_end = clock(); int time = (write_end - write_begin) / (CLOCKS_PER_SEC / 1000);
The result:
Performance result on the physical machine:
Physical machines test fedora kernel: | |||
cpu | memory read | memory write | |
Average: | 13257.6 | 21449.6 | 22243.8 |
Standard deviation: | 4.72 | 17.2 | 18.96 |
SD/E: | 0 | 0 | 0 |
Perf/Perf on Phy: | 100.00% | 100.00% | 100.00% |
Performance result on Dom0:
Dom0 suse kernel test | |||
cpu | memory read | memory write | |
Average: | 13283 | 23059 | 23856.6 |
Standard deviation: | 4.58 | 22.38 | 18.07 |
SD/E: | 0 | 0 | 0 |
Perf/Perf on Phy: | 99.81% | 93.02% | 93.24% |
Performance result on DomU:
DomU fedora kernel test | |||
cpu | memory read | memory write | |
Average: | 13307.6 | 23667.8 | 24459.2 |
Standard deviation: | 13.2 | 33.96 | 37.19 |
SD/E: | 0 | 0 | 0 |
Perf/Perf on Phy: | 99.62% | 90.63% | 90.94% |
From the test, we can see that the CPU performance is nearly 100%. But the memory performance is not so good especially for the DomU. This maybe because of the memory validation of Xen. But the CPU and memory performance of Xen VM is pretty good as a virtual machine.
nice information. thanks.
The memory read and write cant work.. it crashed for memwrite and memread i got time=0
@Teo
Please give me the error message of memwrite and memread.
No optimization should be done by gcc when compiling the code. If -O0 isn’t used, the time may be 0 since the loop actually only read one value at the end and compiler may optimize it to only one operation.