Skip to main content
Version: main

Performance Tips

CPU Isolation​

The Replicated PV Mayastor will fully utilize each CPU core that it was configured to run on. It will spawn a thread on each and the thread will run in an endless loop serving tasks dispatched to it without sleeping or blocking. There are also other IO engine threads that are not bound to the CPU and those are allowed to block and sleep. However, the bound threads (also called reactors) rely on being interrupted by the kernel and other userspace processes as little as possible. Otherwise, the latency of I/O may suffer.

Ideally, the only thing that interrupts IO engine's reactor would be only kernel time-based interrupts responsible for CPU accounting. However, that is far from trivial. isolcpus option that we will be using does not prevent:

  • kernel threads and
  • other k8s pods to run on the isolated CPU

However, it prevents system services including kubelet from interfering with IO engine.

info

If the node runs the Kubernetes CPU Manager with the static policy, read CPU Manager and Core Pinning before choosing cores. kubelet assigns CPUs independently of the core list configured here, and the cores chosen here must be reserved at the node level or the IO engine will fail to start.

Set Linux kernel Boot Parameter​

info

The best way to accomplish this step may differ, based on the Linux distro that you are using.

Add the isolcpus kernel boot parameter to GRUB_CMDLINE_LINUX_DEFAULT in the grub configuration file, with a value which identifies the CPUs to be isolated (indexing starts from zero here). The location of the configuration file to change is typically /etc/default/grub but may vary. For example when running Ubuntu 20.04 in AWS EC2 Cloud boot parameters are in /etc/default/grub.d/50-cloudimg-settings.cfg.

In the following example we assume a system with 4 CPU cores in total, and that the third and the fourth CPU cores are to be dedicated to the IO engine.

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash isolcpus=2,3"

Update Grub​

Command

sudo update-grub

Example Output

Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/40-force-partuuid.cfg'
Sourcing file `/etc/default/grub.d/50-cloudimg-settings.cfg'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.8.0-29-generic
Found initrd image: /boot/microcode.cpio /boot/initrd.img-5.8.0-29-generic
Found linux image: /boot/vmlinuz-5.4.0-1037-aws
Found initrd image: /boot/microcode.cpio /boot/initrd.img-5.4.0-1037-aws
Found Ubuntu 20.04.2 LTS (20.04) on /dev/xvda1
done

Reboot the System​

Command

sudo reboot

Verify Isolcpus​

Basic verification is by outputting the boot parameters of the currently running kernel:

Command

cat /proc/cmdline

Example Output

BOOT_IMAGE=/boot/vmlinuz-5.8.0-29-generic root=PARTUUID=7213a253-01 ro console=tty1 console=ttyS0 nvme_core.io_timeout=4294967295 isolcpus=2,3 panic=-1

You can also print a list of isolated CPUs:

Command

cat /sys/devices/system/cpu/isolated

Example Output

2-3

Update Replicated PV Mayastor Helm Chart for CPU Core Specification​

info

Update the Helm value in the Replicated PV Mayastor Helm chart to specify the CPU core.

To allot specific CPU cores for IO engine's reactors, follow these steps:

  1. Ensure that you have the Replicated PV Mayastor kubectl plugin installed, matching the version of your Replicated PV Mayastor Helm chart deployment (releases). You can find installation instructions in the kubectl plugin documentation.

  2. Execute the following command to update Replicated PV Mayastor's configuration. Replace <namespace> with the appropriate Kubernetes namespace where Replicated PV Mayastor is deployed.

kubectl mayastor upgrade -n <namespace> --set-args 'io_engine.coreList={2,3}'

In the above command, io_engine.coreList={2,3} specifies that IO engine's reactors should operate on the third and fourth CPU cores.

info

The cores are numbered from 0.

Network Isolation​

By default, the NVMe-oF target binds to the node's own IP address. The IO engine runs with host networking, so volume traffic leaves over whichever interface carries that node address, together with everything else on that link. On a busy node, replication and client I/O then compete with the rest of that traffic.

Pointing the target at a dedicated interface — a separate NIC, a VLAN, or a storage-only subnet — keeps that traffic on its own path.

The mayastor.io_engine.target.nvmf.iface Helm value selects the interface. The IP address resolved from it becomes the target address advertised to initiators, and all of the target's listeners share that address, differing only in transport and port. Both application-to-volume traffic and replication between nodes therefore follow the interface you choose.

Select the Interface​

The value takes the form <kind>:<value>:

KindExampleMatches
namename:eth1the interface with that name
subnetsubnet:10.10.0.0/24an interface holding an address inside that CIDR

A value with no prefix is matched as an interface name. An unprefixed CIDR therefore matches nothing, and the IO engine fails to start with Network interface matching '<value>' not found.

subnet: accepts IPv6 CIDRs as well, for example subnet:fd00:10::/64. Note that the value selects the interface, not the address family: the family that ends up published is taken from the IO engine's own gRPC address — IPv4 unless that address is a specific IPv6 one — and falls back to whichever family the matched interface actually has.

One Value Applies to Every Node​

This is a single Helm value, rendered into the IO engine DaemonSet, so every IO engine pod receives the same value. Choose the kind accordingly:

  • Use name: only when the interface carries the same name on every IO engine node.
  • Use subnet: when interface names differ between nodes. Each node independently selects its own interface holding an address in that subnet, which makes it the safer choice for mixed hardware.
info

The interface must exist, be up, and hold an address on every IO engine node. A node where it cannot be resolved will fail to start its IO engine.

Apply the Setting​

At install time:

helm install openebs openebs/openebs -n openebs --create-namespace \
--set mayastor.io_engine.target.nvmf.iface=subnet:10.10.0.0/24

On an existing deployment, use the plugin, which applies the value and restarts the IO engines in one step:

kubectl openebs upgrade -n openebs \
--set mayastor.io_engine.target.nvmf.iface=subnet:10.10.0.0/24
warning

The IO engine DaemonSet uses updateStrategy: OnDelete. Changing the value with helm upgrade alone updates the DaemonSet but leaves the running IO engine pods on their old setting, so the change appears to do nothing until each pod is restarted.

kubectl openebs upgrade performs that restart, one node at a time, moving volume targets off a node before restarting its IO engine. Deleting the pods yourself bypasses that sequencing and will disrupt any volume whose target is hosted on the node you restart.

The target version comes from the chart the upgrade job carries, so a plugin newer than the installed release upgrades that release as well as applying the value. Use a plugin matching the installed release to change the value on its own. See Upgrades.

Restarting an IO engine republishes its targets at the new address, so initiators connected to those targets lose their path. With agents.ha.enabled — the default — the HA node agent re-establishes it; with HA disabled the application sees I/O errors instead. Replicas on the restarted node are rebuilt in full rather than resynced. Treat the change as you would an upgrade rather than a live tunable.

Verify​

The plugin reports the address each IO engine resolved, in the NVMF-TARGET column:

Command

kubectl openebs mayastor get nodes -n openebs

Example Output

ID GRPC-ENDPOINT NVMF-TARGET STATUS VERSION POOLS VOLUMES SNAPSHOTS
worker-1 http://10.0.0.5:10124 nvmf://10.10.0.5 Online v2.13.0 1 1 0
worker-2 http://10.0.0.6:10124 nvmf://10.10.0.6 Online v2.13.0 1 1 0
worker-3 http://10.0.0.7:10124 nvmf://10.10.0.7 Online v2.13.0 1 1 0

Every address under NVMF-TARGET should fall inside the subnet you chose. GRPC-ENDPOINT is the comparison to make: it stays on the node address whatever this setting is, so a node whose two columns still share an address did not pick the setting up. The scheme reads nvmf+rdma+tcp:// where the target also bound RDMA, and the column shows <unknown> against an IO engine too old to report its target.

The column is filled from node registration, so it is available as soon as the IO engines are Online. There is no need to provision a pool or a volume first.

Confirm as well that the nodes can reach one another over the chosen subnet, and if you are using jumbo frames, that the MTU is consistent across every node and switch on the path.

What This Does Not Move​

Only the NVMe-oF data path follows this setting. The IO engine's own gRPC endpoint stays on the node address, as do the HA node agent and the CSI node and controller plugins, which also run with host networking. The control plane agents, the REST API and etcd run as ordinary pods and continue to use the pod network.

Using This with RDMA​

When RDMA is enabled, set the value to a netdev that an RDMA device is bound to, as listed by the rdma link command. See RDMA for the full set of prerequisites.

NUMA Alignment​

On a multi-socket node, the cores the IO engine runs on, the NVMe devices backing its pools and the interface carrying storage traffic should all belong to one NUMA node. Every crossing adds an interconnect hop to the I/O path, and it is easy to do by accident: core numbering, PCIe slot layout and interface naming are independent of one another, so nothing in the settings above lines them up for you.

Find the NUMA Node of Each Component​

The cores that belong to a node:

Command

cat /sys/devices/system/node/node0/cpulist

Example Output

0-15,32-47

The node an NVMe device is attached to:

Command

cat /sys/block/nvme0n1/device/numa_node

The node a network interface is attached to. Resolving it through the PCI address rather than /sys/class/net/<iface>/device/numa_node is the reliable form: for virtio interfaces, and for some SR-IOV setups, that shorter path leads to the virtual device, which carries no numa_node at all.

Command

cat /sys/bus/pci/devices/$(ethtool -i eth0 | awk '/bus-info/ {print $2}')/numa_node
info

A value of -1 means the platform reported no locality for the device. This is normal on virtual machines and on single-socket hosts. Read it as "no constraint", not as a node number.

Applying It​

Once you know which node holds the devices, choose mayastor.io_engine.coreList from that node's cpulist, and set mayastor.io_engine.target.nvmf.iface to an interface on the same node, as described under Network Isolation.

Isolate those same cores with isolcpus, as described under CPU Isolation. The isolated set has to be the cores you picked from this node's cpulist: isolating cores on the other node protects reactors that are not there and leaves the ones that are sharing their cores with the rest of the system, which costs the alignment you just established.

Huge pages are the part Kubernetes will not align for you. The kubelet advertises hugepages-2Mi as a single node-level resource with no NUMA dimension, so the IO engine can be granted pages that were allocated on the other node. Check how they are distributed:

Command

grep . /sys/devices/system/node/node*/hugepages/hugepages-2048kB/nr_hugepages

Example Output

/sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages:1024
/sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages:0

Aligning them means either pre-allocating on the intended node at boot, or enabling the kubelet's Topology Manager with the single-numa-node policy so that CPU, device and memory admission are resolved together.