Skip to content

Commit 4d17e20

Browse files
ixhamzatonyhutter
authored andcommitted
Add zfetch stats in arcstats
arc_summary also reports zfetch stats but it's inconvenient to monitor contiguously incrementing numbers. Adding them in arcstats allows us to observe streams more conveniently. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Ameer Hamza <[email protected]> Closes #16094
1 parent 5972bb8 commit 4d17e20

File tree

1 file changed

+42
-5
lines changed

1 file changed

+42
-5
lines changed

cmd/arcstat.in

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,25 @@ cols = {
157157
"free": [5, 1024, "ARC free memory"],
158158
"avail": [5, 1024, "ARC available memory"],
159159
"waste": [5, 1024, "Wasted memory due to round up to pagesize"],
160+
"ztotal": [6, 1000, "zfetch total prefetcher calls per second"],
161+
"zhits": [5, 1000, "zfetch stream hits per second"],
162+
"zahead": [6, 1000, "zfetch hits ahead of streams per second"],
163+
"zpast": [5, 1000, "zfetch hits behind streams per second"],
164+
"zmisses": [7, 1000, "zfetch stream misses per second"],
165+
"zmax": [4, 1000, "zfetch limit reached per second"],
166+
"zfuture": [7, 1000, "zfetch stream future per second"],
167+
"zstride": [7, 1000, "zfetch stream strides per second"],
168+
"zissued": [7, 1000, "zfetch prefetches issued per second"],
169+
"zactive": [7, 1000, "zfetch prefetches active per second"],
160170
}
161171

162172
v = {}
163173
hdr = ["time", "read", "ddread", "ddh%", "dmread", "dmh%", "pread", "ph%",
164174
"size", "c", "avail"]
165175
xhdr = ["time", "mfu", "mru", "mfug", "mrug", "unc", "eskip", "mtxmis",
166176
"dread", "pread", "read"]
177+
zhdr = ["time", "ztotal", "zhits", "zahead", "zpast", "zmisses", "zmax",
178+
"zfuture", "zstride", "zissued", "zactive"]
167179
sint = 1 # Default interval is 1 second
168180
count = 1 # Default count is 1
169181
hdr_intr = 20 # Print header every 20 lines of output
@@ -206,12 +218,17 @@ elif sys.platform.startswith('linux'):
206218
def kstat_update():
207219
global kstat
208220

209-
k = [line.strip() for line in open('/proc/spl/kstat/zfs/arcstats')]
221+
k1 = [line.strip() for line in open('/proc/spl/kstat/zfs/arcstats')]
210222

211-
if not k:
223+
k2 = ["zfetch_" + line.strip() for line in
224+
open('/proc/spl/kstat/zfs/zfetchstats')]
225+
226+
if k1 is None or k2 is None:
212227
sys.exit(1)
213228

214-
del k[0:2]
229+
del k1[0:2]
230+
del k2[0:2]
231+
k = k1 + k2
215232
kstat = {}
216233

217234
for s in k:
@@ -239,6 +256,7 @@ def usage():
239256
sys.stderr.write("\t -v : List all possible field headers and definitions"
240257
"\n")
241258
sys.stderr.write("\t -x : Print extended stats\n")
259+
sys.stderr.write("\t -z : Print zfetch stats\n")
242260
sys.stderr.write("\t -f : Specify specific fields to print (see -v)\n")
243261
sys.stderr.write("\t -o : Redirect output to the specified file\n")
244262
sys.stderr.write("\t -s : Override default field separator with custom "
@@ -357,6 +375,7 @@ def init():
357375
global count
358376
global hdr
359377
global xhdr
378+
global zhdr
360379
global opfile
361380
global sep
362381
global out
@@ -368,15 +387,17 @@ def init():
368387
xflag = False
369388
hflag = False
370389
vflag = False
390+
zflag = False
371391
i = 1
372392

373393
try:
374394
opts, args = getopt.getopt(
375395
sys.argv[1:],
376-
"axo:hvs:f:p",
396+
"axzo:hvs:f:p",
377397
[
378398
"all",
379399
"extended",
400+
"zfetch",
380401
"outfile",
381402
"help",
382403
"verbose",
@@ -410,13 +431,15 @@ def init():
410431
i += 1
411432
if opt in ('-p', '--parsable'):
412433
pretty_print = False
434+
if opt in ('-z', '--zfetch'):
435+
zflag = True
413436
i += 1
414437

415438
argv = sys.argv[i:]
416439
sint = int(argv[0]) if argv else sint
417440
count = int(argv[1]) if len(argv) > 1 else (0 if len(argv) > 0 else 1)
418441

419-
if hflag or (xflag and desired_cols):
442+
if hflag or (xflag and zflag) or ((zflag or xflag) and desired_cols):
420443
usage()
421444

422445
if vflag:
@@ -425,6 +448,9 @@ def init():
425448
if xflag:
426449
hdr = xhdr
427450

451+
if zflag:
452+
hdr = zhdr
453+
428454
update_hdr_intr()
429455

430456
# check if L2ARC exists
@@ -569,6 +595,17 @@ def calculate():
569595
v["el2mru"] = d["evict_l2_eligible_mru"] // sint
570596
v["el2inel"] = d["evict_l2_ineligible"] // sint
571597
v["mtxmis"] = d["mutex_miss"] // sint
598+
v["ztotal"] = (d["zfetch_hits"] + d["zfetch_future"] + d["zfetch_stride"] +
599+
d["zfetch_past"] + d["zfetch_misses"]) // sint
600+
v["zhits"] = d["zfetch_hits"] // sint
601+
v["zahead"] = (d["zfetch_future"] + d["zfetch_stride"]) // sint
602+
v["zpast"] = d["zfetch_past"] // sint
603+
v["zmisses"] = d["zfetch_misses"] // sint
604+
v["zmax"] = d["zfetch_max_streams"] // sint
605+
v["zfuture"] = d["zfetch_future"] // sint
606+
v["zstride"] = d["zfetch_stride"] // sint
607+
v["zissued"] = d["zfetch_io_issued"] // sint
608+
v["zactive"] = d["zfetch_io_active"] // sint
572609

573610
if l2exist:
574611
v["l2hits"] = d["l2_hits"] // sint

0 commit comments

Comments
 (0)