Skip to content

Before running FEMU

Huaicheng Li edited this page Dec 12, 2020 · 3 revisions

You need to provision resources on your host machine properly to achieve best FEMU performance:

1. To avoid resource contention caused by the noisy neighbors, do not co-run FEMU with other applications on your host server (or at least you need to be sure that your host server has abundant resources to partition between FEMU and your other applications).

2. CPUs: How many CPU cores does FEMU need?

FEMU by default will use up to 8 cores for polling the NVMe Queue Pairs, and the FEMU FTL (in blackbox mode) will consume another CPU core.

Additionally, the FEMU VM will use a few cores as vCPUs (e.g., -cpu 4 in the run-xxx.sh script will reserve 4 CPU cores as vCPUs for the VM).

Finally, your host OS will need at least 1 core.

To sum up, make sure you have enough cores on your physical machine to satisfy the above requirements to avoid CPU contention. Here are some examples given the number of cores you have on your server:

  • On a 8-core server, use -cpu 2 for the FEMU VM, (and FEMU will consume 2-3 cores).
  • On a 16-core server, use -cpu 6 for the FEMU VM, (and FEMU will consume 6-7 cores).
  • On a 32-core server, use -cpu 20 for the FEMU VM, (and FEMU will consume 8-9 cores).
  • On a 48-core server, use -cpu 36 for the FEMU VM, (and FEMU will consume 8-9 cores).

If you prefer to dedicate less cores for FEMU, you can specify -device femu,queues=1,devsz_mb=xxx,femu_mode=xxx. Here queues=1 will limit FEMU to use only 1 polling thread (instead of the default 8 threads). Keep in mind that this will give you worse performance though.

Overall, make sure #FEMU-polling-threads + 1 (#FEMU-FTL-threads) + #FEMU-VM-vCPUs + 1-2 (#Host-OS-cores) <= Total-CPU-cores-in-your-Host.

3. DRAM: How much DRAM will FEMU consume?

Each FEMU NVMe SSD is entire backed by DRAM for accurate NAND timing emulation. Suppose you want to emulate a 16GB SSD, then you need to make sure you have at least 16GB free DRAM for FEMU to use. Remember to reserve enough DRAM for your host OS as well, which usually needs at least 2-4GB, as well as your guest VM (e.g., -m 4G).

Overall, make sure FEMU-SSD-size + VM-DRAM-size + 2-4GB (Host-OS) <= Total-DRAM-size-in-your-Host.

Attention

  • FEMU currently uses its own malloc'ed space for data storage, instead of using image-files.

  • Only Guest Linux version >= 4.14 are supported as FEMU requires the shadow doorbell buffer support in Linux NVMe driver implementation. (Linux 4.12, 4.13 are abandoned due to their wrong implementation in doorbell buffer config support.)

  • Optionally, users can disable the doorbell write operations in guest Linux NVMe driver for optimal performance. Please refer to FEMU Best Practice for how to do this.