Networking DOCA SDK Documentation

DOCA Memos fio Plugin

Introduction

fio is the standard Linux I/O benchmark. The NVIDIA DOCA™ Memos fio Plugin, libdoca_memos_fio_plugin.so, is an fio I/O engine that runs Key/Value (KV) workloads from the host against NVMe KV namespaces, using DOCA Key-Value. It registers the engine name memos_fio and turns fio reads and writes into NVMe KV Retrieve and Store commands. It can exercise and measure any NVMe KV namespace visible to the host, such as the one exposed by the DOCA Memos Initiator reference application, or by DOCA Memos on NVIDIA® BlueField®.

The plugin shows how to use the DOCA Key-Value library:

  • Open an NVMe KV device

  • Create one I/O context per namespace on each thread

  • Submit asynchronous Store and Retrieve tasks

  • Drive completions from a progress engine

The same code is also built as a small standalone sample, doca_memos_fio, which stores one value, retrieves it, and verifies that the two match.

The plugin is not production-ready. Use it only as a reference.

For the end-to-end example that coordinates the host plugin, the BlueField Initiator reference application, and the remote target, see DOCA Memos Reference Application. For the BlueField application, see DOCA Memos Initiator Application.

System Design

The following diagram shows the plugin's I/O path on the host:

 Host
+-----------------------------------------------------------+
| fio                                                        |
|  ioengine = libdoca_memos_fio_plugin.so                    |
|   job thread 1..N: own PE + KV I/O context per namespace   |
|        | io_uring NVMe passthrough                         |
|  /dev/ngXnY  (NVMe KV namespace, generic char device)      |
+-----------------------------|-----------------------------+
                              v
            NVMe KV controller (e.g. BlueField emulated function)

Application Architecture

  • The plugin opens each path in filename=: colon-separated NVMe generic character devices, up to 8. It reads the namespace globally unique identifier (NGUID) of each namespace from the device and starts one DOCA Key-Value device per path.

  • Each fio job thread (numjobs=) gets its own progress engine and one DOCA Key-Value I/O context per namespace. Each context is configured with iodepth task slots; fio limits the job's outstanding I/O through iodepth.

  • The plugin maps fio operations to KV commands as follows:

fio Operation

KV Command

read, randread

Retrieve

write, randwrite

Store

rw, readwrite, randrw

Mixed (rwmixread= sets the read share)

Other I/O directions, such as trim, are rejected. There is no engine option for the operation; it comes from rw=.

  • Each KV key is 8 bytes: a hash of the fio byte offset (hash_type=). The same offset therefore always maps to the same key, on every thread.

  • size= sets the key range: size / bs keys. A KV namespace reports no usable capacity (some targets report the maximum 64-bit value), so always set size=.

  • The value is the fio buffer (bs= bytes). It is split into kv_iovcnt equal iovecs, so the engine can exercise vectored (multi-segment) KV commands; the last iovec absorbs any remainder.

DOCA Libraries

This application uses the following DOCA libraries:

Dependencies

  • Build time:

    • A configured fio source tree (./configure run), matching the fio binary you run.

    • Linux kernel headers 6.2 or later (NVMe io_uring passthrough).

    • liburing 2.5 or later.

  • Run time:

    • Linux kernel 6.2 or later on the host (on Ubuntu 22.04, the hardware enablement (HWE) kernel).

    • An NVMe KV namespace visible as /dev/ngXnY, identified by its NGUID (nvme id-ns /dev/ngXnY), because numbering can change between boots.

    • Root access, or read/write permission on the device.

    • 2 MiB hugepages for mem=mmaphuge: reserve enough for numjobs × iodepth × bs plus headroom, for example sysctl -w vm.nr_hugepages=1024 (2 GiB). The reservation does not survive a reboot.

Installing the Plugin

DOCA-Host supplies the Memos fio plugin source code through the doca-samples package, not a prebuilt libdoca_memos_fio_plugin.so. Build and install the plugin before running fio. A separate Memos fio tar file is not required.

For DOCA 3.6, use doca-samples version 3.6.0079-1 or a later matching 3.6 package containing the plugin sources. Install the matching DOCA Common and DOCA Key-Value development packages from the same DOCA-Host release. Follow the DOCA Installation Guide for Linux to obtain DOCA-Host and configure its package repository for the host operating system and architecture.

On Ubuntu, after configuring that repository, install the source and development packages:

Bash
sudo apt-get update
sudo apt-get install -y doca-samples libdoca-sdk-common-dev libdoca-sdk-kv-dev

dpkg-query -W doca-samples libdoca-sdk-common-dev libdoca-sdk-kv-dev
test -f /opt/mellanox/doca/applications/memos_fio_plugin/meson.build

The plugin source directory is /opt/mellanox/doca/applications/memos_fio_plugin/. If it is absent, check the installed doca-samples version and repository before proceeding; installing the runtime libraries alone does not supply these sources.

Continue with Compiling the Application. Use fio headers that match the fio binary that loads the plugin, and run against the same DOCA library installation that you use for the build.

Compiling the Application

Refer to the DOCA Installation Guide for Linux for software installation instructions.

Install the source and development packages as described in Installing the Plugin before following either build procedure.

For development and compilation guidance, see DOCA Reference Applications.

The examples in this section assume that the application sources are installed in the following directory:

/opt/mellanox/doca/applications/memos_fio_plugin/

Primary Option: Use OS-packaged fio on Ubuntu 24.04

Use Ubuntu's fio package as the runtime. Only the DOCA Memos fio plugin is compiled; fio itself is not rebuilt or installed from GitHub. The plugin requires fio's internal headers and generated configuration header, so obtain the matching Ubuntu source package and configure it for the build.

This procedure is for an Ubuntu 24.04 x86-64 host. Complete the following procedures in order. If DOCA is installed in a different prefix, adjust DOCA_ROOT. For the NVMe KV device and workload prerequisites, see Dependencies and Running the Application.

Install fio and Plugin Build Dependencies

Bash
sudo apt-get update
sudo apt-get install -y \
    fio build-essential dpkg-dev meson ninja-build pkg-config \
    libaio-dev liburing-dev libbsd-dev libxxhash-dev

fio --version
dpkg-query -W fio

Obtain Matching fio Headers From Ubuntu

Enable Ubuntu source repositories. In the standard Ubuntu 24.04 configuration, edit /etc/apt/sources.list.d/ubuntu.sources and change Types: deb to Types: deb deb-src in the Ubuntu repository stanzas. Keep the existing suites, components, and signing settings unchanged. Include the update and security source repositories used by the installed fio package; do not apply this change to NVIDIA repository entries.

Bash
sudo apt-get update
mkdir -p "$HOME/fio-headers"
cd "$HOME/fio-headers"

FIO_PACKAGE_VERSION=$(dpkg-query -W -f='${Version}' fio)
apt-get source "fio=$FIO_PACKAGE_VERSION"

FIO_VERSION=$(fio --version | sed 's/^fio-//')
export FIO_SOURCE="$PWD/fio-$FIO_VERSION"
cd "$FIO_SOURCE"
./configure --disable-native --prefix=/usr

test -f fio.h
test -f config-host.h

apt-get source extracts the Ubuntu source package; it does not replace the installed fio binary. ./configure generates config-host.h. Do not run make or make install in the fio source tree for this option. Pass this configured tree to Meson using fio_prefix.

The source version and build configuration must be compatible with the installed fio binary. If the exact source package version is unavailable, resolve the Ubuntu repository/version mismatch before proceeding; do not substitute an arbitrary fio GitHub revision. After you upgrade the fio package, rebuild the plugin against matching headers.

Select the Installed DOCA Libraries

Bash
export DOCA_ROOT=/opt/mellanox/doca
export DOCA_LIBDIR="$DOCA_ROOT/lib/x86_64-linux-gnu"
export PKG_CONFIG_PATH="$DOCA_LIBDIR/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
export LD_LIBRARY_PATH="$DOCA_LIBDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"

pkg-config --modversion doca-common doca-kv

Both packages must resolve to the intended DOCA installation. If either is missing, install the matching DOCA development packages before continuing. Do not mix libraries from different DOCA installations.

Build and Install Only the fio Plugin

Bash
export FIO_PLUGIN_BUILD="$HOME/doca-fio-plugin-build"

meson setup "$FIO_PLUGIN_BUILD" "$DOCA_ROOT/applications" \
    --buildtype=release \
    -Denable_all_applications=false \
    -Denable_memos_fio_plugin=true \
    -Dfio_prefix="$FIO_SOURCE"

ninja -C "$FIO_PLUGIN_BUILD" \
    memos_fio_plugin/libdoca_memos_fio_plugin.so

sudo install -m 0755 \
    "$FIO_PLUGIN_BUILD/memos_fio_plugin/libdoca_memos_fio_plugin.so" \
    "$DOCA_LIBDIR/libdoca_memos_fio_plugin.so"

Run Meson against the parent applications directory, not the plugin subdirectory. Use a new build directory for the initial meson setup. These commands compile and install the external plugin only, leaving Ubuntu's fio executable unchanged.

Verify Plugin Loading and Select It in a Job

Bash
export FIO_PLUGIN="$DOCA_LIBDIR/libdoca_memos_fio_plugin.so"

fio --enghelp="$FIO_PLUGIN"
dpkg --verify fio

The first command loads the plugin and displays its engine-specific options. If the packaged fio files are unchanged, dpkg --verify fio produces no output. These checks verify plugin loading, not an actual KV I/O workload.

Set the job file's ioengine to the absolute path of the installed plugin:

Bash
ioengine=/opt/mellanox/doca/lib/x86_64-linux-gnu/libdoca_memos_fio_plugin.so

Run the job with fio. Keep the DOCA library environment from Select the Installed DOCA Libraries. If you run fio with elevated privileges, pass the library path explicitly:

Bash
sudo env LD_LIBRARY_PATH="$LD_LIBRARY_PATH" fio memos_fio.fio

Configure the device, workload, and memory settings as described in Running the Application.

Alternative Option: Build fio From Source

Use this option only when a source-built fio is required. The plugin is compiled against the headers of the same configured fio source tree, passed with fio_prefix. Run the fio binary built from that tree rather than mixing it with the OS-packaged binary. For example, to clone and build fio, run:

Bash
git clone https://github.com/axboe/fio.git && cd fio
./configure && make -j

If fio_prefix is not set, or does not point at a configured fio tree, the plugin is skipped and the Meson log gives the reason. The standalone sample doca_memos_fio does not need fio.

Compiling All Applications

All DOCA applications are defined in a single Meson project, so by default the build includes all of them.

To build all the applications together, run:

cd /opt/mellanox/doca/applications/
meson /tmp/build -Dfio_prefix=<path-to-fio-source>
ninja -C /tmp/build

libdoca_memos_fio_plugin.so and doca_memos_fio are created under /tmp/build/memos_fio_plugin/.

Compiling Only the Current Application

To build only the DOCA Memos fio Plugin, run:

cd /opt/mellanox/doca/applications/
meson /tmp/build -Denable_all_applications=false -Denable_memos_fio_plugin=true -Dfio_prefix=<path-to-fio-source>
ninja -C /tmp/build

libdoca_memos_fio_plugin.so and doca_memos_fio are created under /tmp/build/memos_fio_plugin/.

Alternatively, you can set the flags in the meson_options.txt file instead of on the command line:

  1. Edit the following flags in /opt/mellanox/doca/applications/meson_options.txt:

    • Set enable_all_applications to false

    • Set enable_memos_fio_plugin to true

    • Set fio_prefix to the fio source tree

  2. Run the following compilation commands:

cd /opt/mellanox/doca/applications/
meson /tmp/build
ninja -C /tmp/build

libdoca_memos_fio_plugin.so and doca_memos_fio are created under /tmp/build/memos_fio_plugin/.

Running the Application

Run With the Example Job File

Edit the example job file, /opt/mellanox/doca/applications/memos_fio_plugin/memos_fio.fio: set ioengine= to the absolute path of the plugin and filename= to your device. The file uses bs=4k and size=512k (128 keys), runs a timed random read/write mix, and continues past reads of keys that were never stored. If your namespace allows larger values, raise bs= up to its maximum value length. Then run:

sudo fio memos_fio.fio

Options set in the job file take precedence over the same options given on the command line after it. To change numjobs, iodepth, bs, size, or an engine option such as kv_iovcnt, edit the job file. If the plugin is on fio's plugin path, ioengine=memos_fio is enough.

Run From the Command Line

The following example stores 128 keys with 4 KiB values and then verifies them. Keep bs within the namespace's advertised maximum value length. Replace the plugin path with the path of your installed or locally built plugin:

fio --name=kv --ioengine=<path-to-plugin.so> \
    --filename=/dev/ng0n1 --rw=write --bs=4k --size=512k --iodepth=8 --numjobs=1 \
    --thread=1 --kv_iovcnt=1 --mem=mmaphuge --verify=crc32c --do_verify=1

A read or mixed workload must tolerate reads of keys that were never stored, which complete with ENOENT. Add --continue_on_error=read --ignore_error=ENOENT, and use the same --size, --bs, and --hash_type as the write run so that the reads cover the stored keys. If keys were stored with a different bs, also ignore ENODATA (--ignore_error=ENOENT:ENODATA).

For example, to read the keys that the previous example stored, run:

fio --name=read --ioengine=<path-to-plugin.so> \
    --filename=/dev/ng0n1 --rw=read --bs=4k --size=512k --iodepth=8 --numjobs=1 \
    --thread=1 --mem=mmaphuge --continue_on_error=read --ignore_error=ENOENT

Put --ioengine= before any engine-specific option; fio accepts the engine's options only after it has loaded the engine. fio --enghelp=<path-to-plugin.so> lists the engine options.

Engine Options

Option

Default

Description

kv_iovcnt

1

Number of iovecs each KV value is split into (1–56). bs must be at least kv_iovcnt bytes.

hash_type

2

Offset-to-key hash: 1 = xxh64, 2 = splitmix64, 3 = murmur3_64. 0 or omitted selects 2; other values fail validation.

fio-log-level

0 (INFO)

Lower limit for the plugin's own DOCA log messages

doca-log-level

0 (WARNING)

DOCA SDK log limit

Log levels use the numeric DOCA scale: 0 = the default listed in the table, 10 = DISABLE, 20 = CRITICAL, 30 = ERROR, 40 = WARNING, 50 = INFO, 60 = DEBUG, 70 = TRACE.

The following standard fio options are relevant to the plugin:

Option

Notes

filename

Required. Colon-separated /dev/ngXnY paths, up to 8.

size

Required: the key range (size / bs keys). For example, size=512k with bs=4k gives 128 keys. See limitation 1.

bs

Value size per operation. Keep it within the namespace's maximum value length.

numjobs

Parallel KV I/O threads, each with its own progress engine. At most the number of online CPUs (nproc), and at most 32.

iodepth

Maximum outstanding fio I/O per job. The plugin configures this task count per namespace I/O context. The maximum is 256, or a lower limit reported by doca_kv_io_cap_get_max_tasks().

mem

mmaphuge (recommended) or malloc

Standalone Sample

The standalone sample, doca_memos_fio, stores one value, retrieves it, and verifies that the two match. For example, run:

doca_memos_fio -d /dev/ng0n1 -l 4096 -p both

Set -l to no more than the namespace's advertised maximum value length. The default is 8 MiB; override it when the namespace supports smaller values.

Flag

Description

-d, --device

NVMe character device path (required)

-l, --value-len

Value size: at least 4 KiB and 4 KiB aligned (default 8 MiB)

-t, --hash-type

Offset-to-key hash, as for the hash_type engine option (default 2)

-o, --offset

Byte offset used to derive the key (default 0)

-p, --operation

store, retrieve, or both (default both)

Limitations

  1. Explicit workload size is required. KV namespace capacity does not provide a reliable fio workload range and might be reported as an unusable or sentinel value. Always set size=; for a fixed bs, it defines a range of size / bs keys. The plugin does not validate that this key range fits the backend's available storage. Choose a range appropriate for the namespace and use the same size, bs, and hash_type for matching Store/Retrieve runs.

  2. Only KV Store and Retrieve are issued. Exist, Delete, and List are not used.

  3. Keys are derived from offsets. Do not combine --verify with numjobs greater than 1: jobs share offsets, so they overwrite each other's keys and verification fails.

  4. Reading a key that was never stored completes with ENOENT; read and mixed jobs need continue_on_error=read and ignore_error=ENOENT.

  5. The key range must fit the intended backend retention behavior. On a backend that evicts older keys when full, exceeding its capacity can cause subsequent reads or verification to fail.

  6. Large values need hugepage buffers (mem=mmaphuge); ordinary 4 KiB-page buffers might fail for large values.

Troubleshooting

Symptom

Cause and Action

unrecognized option for an engine option

Put --ioengine=<plugin .so> before the engine options, or put them in the job file.

fio fails to load the engine with undefined symbols

The plugin was built against a different fio tree than the fio binary. Rebuild with the matching fio_prefix.

Device start fails or is not supported

The kernel is earlier than 6.2, or the path is not an NVMe KV namespace. Check uname -r and nvme id-ns.

write bs=8192 exceeds device max_value_len=4096

bs is larger than the namespace's maximum value length. Lower bs, in the job file if it sets it.

A read job stops at the first read

Add --continue_on_error=read --ignore_error=ENOENT, and check that the reads use the same size, bs, and hash_type as the write run.

Verify errors with numjobs > 1

Expected with offset-derived keys. Verify with numjobs=1.

BAD configuration: num_io_threads=N exceeds online CPU count

numjobs is larger than nproc. Set numjobs to at most the number of online CPUs (nproc).

Requested Resource Not Found at initialization

DOCA Key-Value could not match the namespace by NGUID. Check that nvme id-ns /dev/nvmeX -n 1 shows a nonzero NGUID.

error while loading shared libraries: libdoca_kv.so.2

LD_LIBRARY_PATH does not include the DOCA library directory. Export it as described in Select the Installed DOCA Libraries. With sudo, pass it through sudo env.

The startup log shows a different DOCA version than the plugin was built with

The fio binary already loaded other DOCA libraries. Point LD_LIBRARY_PATH at the DOCA libraries the plugin was built against.

Buffer allocation or mmap fails at startup

Not enough hugepages for numjobs × iodepth × bs. Check grep HugePages_ /proc/meminfo.

/dev/ngXnY disappears after a controller reset

Run nvme ns-rescan /dev/nvmeX.

Application Code Flow

The fio engine is an adapter over the DOCA Key-Value library. Its callbacks drive the library's device, I/O-context, and asynchronous task lifecycle; fio supplies the workload, buffers, and completion reporting. The plugin uses the NVMe kernel backend of DOCA Key-Value.

  1. Setup: create DOCA Key-Value devices. memos_fio_plugin_setup() initializes the shared plugin state. For each namespace, the plugin configures a character-device path and expected NGUID in creation attributes, then calls doca_kv_nvme_kernel_dev_create(). Device creation synchronously attaches to the namespace and loads its properties; the library device has no separate DOCA start/stop context.

  2. Setup: initialize DOCA Key-Value I/O contexts. Each fio thread owns a progress engine and, in this plugin, one doca_kv_nvme_kernel_io per namespace. The plugin configures task counts and completion/error callbacks through doca_kv_io and connects each context to its progress engine. It then starts each context and explicitly binds its KV device with doca_kv_io_bind_dev(). The library also permits one I/O context to serve multiple bound devices; the per-namespace arrangement is the plugin's choice.

  3. Open file: select the namespace binding. memos_fio_plugin_open() associates the fio file with the previously created device and the current thread's I/O context for that namespace.

  4. Queue: allocate and submit a DOCA Key-Value task. memos_fio_plugin_queue() derives the key from the fio offset. The thread helper allocates a Store or Retrieve task with doca_kv_io_task_store_alloc_init() or doca_kv_io_task_retrieve_alloc_init(), passing both the running I/O context and its bound device. It configures the key/value buffers and submits the converted DOCA task with doca_task_submit(). The plugin checks namespace transfer limits; it does not validate that the configured fio key range fits backend storage. See limitation 1.

  5. Get events: progress DOCA Key-Value and collect completions. memos_fio_plugin_getevents() progresses the thread's engine. DOCA Key-Value invokes the registered success or error callback, returning task ownership to the plugin. The plugin records the result and frees the DOCA task.

  6. Event: report the result to fio. memos_fio_plugin_event() returns completed I/O to fio. The plugin maps DOCA_ERROR_NOT_FOUND to ENOENT and reports ENODATA when a successful Retrieve returns a value length different from the requested fio length. These errno mappings are plugin behavior, not DOCA Key-Value status codes.

  7. Cleanup: release DOCA Key-Value resources. After outstanding tasks have completed and been freed, the plugin unbinds devices, stops and destroys the I/O contexts, and destroys the devices once all bindings have been removed.

For DOCA Key-Value device, I/O-context, and task programming flows, see DOCA Key-Value. For other library programming guides, see DOCA Libraries. Use API References for signatures and contracts matching the installed SDK.

The following table describes the plugin source files:

File

Role

memos_fio_plugin.c

fio engine registration, options, setup and cleanup, queue and completion handling

memos_fio_plugin_dev.c

DOCA Key-Value NVMe kernel device lifecycle

memos_fio_plugin_dev_io.c

DOCA Key-Value I/O context lifecycle

memos_fio_plugin_thread.c

Per-fio-thread state, asynchronous store and retrieve

memos_fio_utils.c

Logging, device path parsing, NGUID query, offset-to-key hashing

memos_fio.c

Standalone sample (doca_memos_fio)

memos_fio.fio

Annotated example job file

Last updated: