# VM Memcached Performance Test
First, fix CPU Frequency
Then, adjust host transparent hugepage usage, e.g.
```
echo always | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
```
Start original/contiguous qemu pinning 16 cpus (2-17), with 10 cores and 64G memories. (for contigous kernel, using 58 cma area)
```
sudo taskset -c 2-17 qemu-system-x86_64 \
-name vmemcached-server,debug-threads=on \
-enable-kvm \
-cpu host,pdpe1gb \
-smp 10 -m 65536 \
-nographic \
-s \
-drive file=/u2/fanyuex/ubuntu-qemu/ubuntu2204-server-cloudimg-amd64.qcow2,if=virtio,format=qcow2 \
-device virtio-net-pci,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::3333-:22 \
-kernel /u2/fanyuex/kernel-images/contiguous-bzImage \
-append "console=ttyS0 root=/dev/vda3 loglevel=8 hugetlb_cma=58G"
```
adjust guest transparent hugepage usage
start the memcached server (pinning 4 virtual cores, 80000 connections, maximum 64G memories (-M to keep below maximum, 4 threads)
```
taskset -c 0-3 ./memcached -c 80000 -m 65536 -M -t 4
```
fill the server with memtier_benchmark (pinning another 4 virtual cores, using 500 connections, 4 threads, all write requests, object size random from 10-1024)
```
taskset -c 4-7 memtier_benchmark \
-p 11211 \
-P memcache_binary \
-n 'allkeys' \
-c 500 \
-t 4 \
--pipeline=100 \
--ratio=1:0 \
--data-size-pattern=R \
--data-size-range=10-1024 \
--key-maximum=81281788 \
--key-pattern=P:P
```
After this, htop will show roughly 51.6G/62.3G memory usages.
Then run the actual benchmark client with the same key range, onject size as before, but with write:read ratio set to 7:100 (according to *nsdi21-yang* paper) and in total 100000 requests.
```
taskset -c 4-7 memtier_benchmark \
-n 100000 \
-p 11211 \
-P memcache_binary \
-c 500 \
-t 4 \
--ratio=7:100 \
--data-size-pattern=R \
--data-size-range=10-1024 \
--key-maximum=81281788 \
--key-pattern=G:G
```
Run the experiment 3 times for each configuration, make sure each time, restart and refill the server.
It should take about 6/7 minutes to run the benchmark