tests/test-offset: Create the test file in the test itself.
[nbdkit/ericb.git] / BENCHMARKING
blobdee3aa968a6965f473a38066d42573b65550518c
1 A guide to benchmarking nbdkit
2 ==============================
5 General comments
6 ----------------
8 * The plugin matters!  Different plugins have completely different
9   uses, implementations and threading models.  There is little point
10   in talking generically about “the performance of nbdkit” without
11   mentioning what plugin you are testing.
13 * The client matters!  Does the client support multi-conn?  Does the
14   client use the oldstyle or newstyle protocol?  Has the client been
15   written with performance in mind?  The currently best clients are
16   (a) the Linux kernel (nbd.ko), (b) qemu, and (c) fio.  Make sure you
17   are using recent versions and have multi-conn enabled.
19 * Filters affect performance.  When benchmarking you should never use
20   filters unless filters are what you are trying to benchmark.
23 Testing using fio
24 -----------------
26 FIO is a Flexible I/O tester written by Jens Axboe, and it is the
27 primary tool used for generating the load to test filesystems and
28 block devices.
30 (1) Install libnbd.
32 (2) Clone and compile fio:
34     https://github.com/axboe/fio
36 using:
38     ./configure --enable-libnbd
40 (3) Edit the test file in examples/nbd.fio, if required.
42 (4) Run nbdkit and fio together.  From the fio source directory:
44     rm -f /tmp/socket
45     nbdkit -f -U /tmp/socket null 1G --run './fio examples/nbd.fio'
47 If you want to use nbdkit from the source directory too, change
48 ‘nbdkit’ to the path of the wrapper, eg:
50     rm -f /tmp/socket
51     ../nbdkit/nbdkit -f -U /tmp/socket null 1G --run './fio examples/nbd.fio'
54 Variations
55 ----------
57 * Try adjusting the number of fio jobs (threads).
59 * Try adjusting the number of nbdkit threads (nbdkit -t option).
61 * Use other plugins.  Both nbdkit-memory-plugin and nbdkit-file-plugin
62   are important ones to test.
64 * Run nbdkit under perf:
66   perf record -a -g --call-graph=dwarf -- \
67       server/nbdkit  -f -U /tmp/socket \
68           ./plugins/null/.libs/nbdkit-null-plugin.so 1G
71 Testing using the Linux kernel client
72 -------------------------------------
74 Step (1) is the same as above - obtain or compile fio.
76 (2) Create the fio configuation file.
78 Create /var/tmp/test.fio containing:
80 ----------------------------------------------------------------------
81 [test]
82 rw=randrw
83 size=64m
84 directory=/var/tmp/nbd
85 ioengine=libaio
86 iodepth=4
87 direct=1
88 numjobs=8
89 group_reporting
90 time_based
91 runtime=120
92 ----------------------------------------------------------------------
94 (3) Run nbdkit.
96 From the nbdkit source directory:
98 rm -f /tmp/socket
99 ./nbdkit -f -U /tmp/socket memory 1G
101 (4) Loop mount the NBD server:
103 modprobe nbd
104 nbd-client -C 8 -b 512 -unix /tmp/socket /dev/nbd0
105 mkfs.xfs -f /dev/nbd0
106 mkdir /var/tmp/nbd
107 mount /dev/nbd0 /var/tmp/nbd
109 (5) Run the fio test:
111 fio /var/tmp/test.fio