Skip to content

Commit ff2cfbd

Browse files
Nikratiorwmjones
authored andcommitted
stats-filter: bucket request sizes and only count successful requests
(1) Group requests into buckets corresponding to the number of bits needed to represent the request size. Keeping track of every encountered request size has turned out often to be useless in practice since e.g. ZFS can issue a very large number of differently sizes requests. (2) Record only successful requests in the histogram to make the histogram consistent with the total. (3) Simplify the code by handling the collection of histogram data in the same structure and function as the other statistics. (4) Introduce an assertion when the histogram total differs from the separately calculated total (to track down issue #7). Some code had to be moved around to ensure that functions are defined before they are called. (cherry picked from commit 9f0226e)
1 parent e7af77e commit ff2cfbd

File tree

2 files changed

+193
-176
lines changed

2 files changed

+193
-176
lines changed

filters/stats/nbdkit-stats-filter.pod

+53-39
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,55 @@ are written to a file once when nbdkit exits.
1515

1616
=head1 EXAMPLE OUTPUT
1717

18-
# nbdkit --filter=exitfirst --filter=stats memory 25G statsfile=example.txt
19-
# nbd-client localhost /dev/nbd1 && mkfs.ext4 /dev/nbd1 &&
18+
# nbdkit --filter=exitlast --filter=stats memory 25G statsfile=example.txt
19+
# nbd-client localhost /dev/nbd1 && mkfs.ext4 /dev/nbd1 && sync &&
2020
nbd-client -d /dev/nbd1
2121
[....]
2222
# cat example.txt
23-
total: 1252 ops, 3.395897 s, 25.13 GiB, 7.40 GiB/s
24-
read: 145 ops, 0.000133 s, 3.04 MiB, 22.34 GiB/s op, 917.58 KiB/s total
25-
write: 1088 ops, 0.065065 s, 132.38 MiB, 1.99 GiB/s op, 38.98 MiB/s total
26-
trim: 14 ops, 0.002037 s, 25.00 GiB, 12272.95 GiB/s op, 7.36 GiB/s total
27-
flush: 5 ops, 0.000002 s, 0 bytes, 0 bytes/s op, 0 bytes/s total
28-
29-
READ request sizes:
30-
4096 bytes: 66.2% of requests (96)
31-
12 bit aligned: 100.0% (96)
32-
13 bit aligned: 69.8% (67)
33-
14 bit aligned: 54.2% (52)
34-
15 bit aligned: 46.9% (45)
35-
16 bit aligned: 41.7% (40)
36-
17 bit aligned: 36.5% (35)
37-
18 bit aligned: 31.2% (30)
38-
19+ bit-aligned: 28.1% (27)
39-
16384 bytes: 4.8% of requests (7)
40-
13 bit aligned: 100.0% (7)
41-
17 bit aligned: 71.4% (5)
42-
19 bit aligned: 42.9% (3)
43-
other sizes: 29.0% of requests (42)
44-
45-
WRITE request sizes:
46-
131072 bytes: 97.1% of requests (1056)
47-
17 bit aligned: 100.0% (1056)
48-
18 bit aligned: 50.0% (528)
49-
19+ bit-aligned: 25.0% (264)
50-
other sizes: 2.9% of requests (32)
51-
52-
TRIM request sizes:
53-
2147483648 bytes: 85.7% of requests (12)
23+
total: 191 ops, 21.917545 s, 25.13 GiB, 1.15 GiB/s
24+
read: 136 ops, 0.000230 s, 3.16 MiB, 13.43 GiB/s op, 147.83 KiB/s total
25+
Request size and alignment breakdown:
26+
12 bits: 68.4% (93 reqs, 372.00 KiB total)
27+
12 bit aligned: 100.0% (93)
28+
13 bit aligned: 72.0% (67)
29+
14 bit aligned: 55.9% (52)
30+
15 bit aligned: 48.4% (45)
31+
16 bit aligned: 43.0% (40)
32+
14 bits: 10.3% (14 reqs, 296.00 KiB total)
33+
12 bit aligned: 100.0% (14)
34+
13 bit aligned: 35.7% (5)
35+
19 bit aligned: 21.4% (3)
36+
[....]
37+
other sizes: 3.7% (5 reqs, 3.16 MiB total)
38+
39+
write: 36 ops, 0.125460 s, 132.38 MiB, 1.03 GiB/s op, 6.04 MiB/s total
40+
Request size and alignment breakdown:
41+
12 bits: 50.0% (18 reqs, 72.00 KiB total)
42+
12 bit aligned: 100.0% (18)
43+
13 bit aligned: 77.8% (14)
44+
27 bit aligned: 72.2% (13)
45+
31 bit aligned: 66.7% (12)
46+
32 bit aligned: 33.3% (6)
47+
33 bit aligned: 22.2% (4)
48+
34 bit aligned: 11.1% (2)
49+
14 bits: 30.6% (11 reqs, 224.00 KiB total)
50+
12 bit aligned: 100.0% (11)
51+
27 bit aligned: 90.9% (10)
52+
25 bits: 11.1% (4 reqs, 128.00 MiB total)
53+
25 bit aligned: 100.0% (4)
54+
26 bit aligned: 50.0% (2)
55+
27 bit aligned: 25.0% (1)
56+
16 bits: 2.8% (1 reqs, 64.00 KiB total)
57+
16 bit aligned: 100.0% (1)
58+
59+
trim: 14 ops, 0.002687 s, 25.00 GiB, 9304.06 GiB/s op, 1.14 GiB/s total
60+
Request size and alignment breakdown:
61+
31 bits: 85.7% (12 reqs, 24.00 GiB total)
5462
24 bit aligned: 100.0% (12)
55-
other sizes: 14.3% of requests (2)
63+
24 bits: 7.1% (1 reqs, 16.00 MiB total)
64+
65+
flush: 5 ops, 0.000002 s, 0 bytes, 0 bytes/s op, 0 bytes/s total
5666

57-
ZERO request sizes:
58-
(no such requests)
5967

6068
=head1 PARAMETERS
6169

@@ -73,9 +81,15 @@ If set then we append to the file instead of replacing it.
7381

7482
=item B<statsthreshold=>PERCENTILE
7583

76-
Percentile of requests for which block size histogram should be printed.
77-
Set to zero to disable collection of block size statistics. Set to 100
78-
to get a list of every block size encountered. Default: 95.
84+
If non-zero, track request size and alignment distribution and print
85+
histogram.
86+
87+
Requests are grouped by the number of bits that are needed to represent
88+
the request size (e.g. a request of size 3892 needs will be grouped
89+
with all requests of size 2^11=2048 to 2^12-1=4095), and the number of
90+
trailing zero bits in the offset.
91+
92+
Histogram output is truncated to PERCENTILE of requests. Default: 95.
7993

8094
=back
8195

0 commit comments

Comments
 (0)