A Simple CPU and Memory Performance Test of Xen Dom0 and DomU

Please 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:

cpumemory readmemory write
Average:13257.621449.622243.8
Standard deviation:4.7217.218.96
SD/E:000




Perf/Perf on Phy:100.00%100.00%100.00%

Performance result on Dom0:


Dom0 suse kernel test

cpumemory readmemory write
Average:132832305923856.6
Standard deviation:4.5822.3818.07
SD/E:000




Perf/Perf on Phy:99.81%93.02%93.24%

Performance result on DomU:


DomU fedora kernel test

cpumemory readmemory write
Average:13307.623667.824459.2
Standard deviation:13.233.9637.19
SD/E:000




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.

About Eric Zhiqiang Ma

Eric Zhiqiang Ma is a PhD candidate at Dep. of CSE, HKUST. He is interested in system software for cloud computing, virtualization of large-scale distributed systems and etc. Also find Eric on Facebook, Twitter, LinkedIn and Google+. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties. More Posts - Website

3 thoughts on “A Simple CPU and Memory Performance Test of Xen Dom0 and DomU”

  1. @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.

Leave a Reply

Your email address will not be published. Required fields are marked *

88 − = eighty three

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Click to subscribe to Fclose.com Posts by Email if you have not.