@@ -157,13 +157,25 @@ cols = {
157
157
"free": [5, 1024, "ARC free memory"],
158
158
"avail": [5, 1024, "ARC available memory"],
159
159
"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"],
160
170
}
161
171
162
172
v = {}
163
173
hdr = ["time", "read", "ddread", "ddh%", "dmread", "dmh%", "pread", "ph%",
164
174
"size", "c", "avail"]
165
175
xhdr = ["time", "mfu", "mru", "mfug", "mrug", "unc", "eskip", "mtxmis",
166
176
"dread", "pread", "read"]
177
+ zhdr = ["time", "ztotal", "zhits", "zahead", "zpast", "zmisses", "zmax",
178
+ "zfuture", "zstride", "zissued", "zactive"]
167
179
sint = 1 # Default interval is 1 second
168
180
count = 1 # Default count is 1
169
181
hdr_intr = 20 # Print header every 20 lines of output
@@ -206,12 +218,17 @@ elif sys.platform.startswith('linux'):
206
218
def kstat_update():
207
219
global kstat
208
220
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')]
210
222
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:
212
227
sys.exit(1)
213
228
214
- del k[0:2]
229
+ del k1[0:2]
230
+ del k2[0:2]
231
+ k = k1 + k2
215
232
kstat = {}
216
233
217
234
for s in k:
@@ -239,6 +256,7 @@ def usage():
239
256
sys.stderr.write("\t -v : List all possible field headers and definitions"
240
257
"\n")
241
258
sys.stderr.write("\t -x : Print extended stats\n")
259
+ sys.stderr.write("\t -z : Print zfetch stats\n")
242
260
sys.stderr.write("\t -f : Specify specific fields to print (see -v)\n")
243
261
sys.stderr.write("\t -o : Redirect output to the specified file\n")
244
262
sys.stderr.write("\t -s : Override default field separator with custom "
@@ -357,6 +375,7 @@ def init():
357
375
global count
358
376
global hdr
359
377
global xhdr
378
+ global zhdr
360
379
global opfile
361
380
global sep
362
381
global out
@@ -368,15 +387,17 @@ def init():
368
387
xflag = False
369
388
hflag = False
370
389
vflag = False
390
+ zflag = False
371
391
i = 1
372
392
373
393
try:
374
394
opts, args = getopt.getopt(
375
395
sys.argv[1:],
376
- "axo :hvs:f:p",
396
+ "axzo :hvs:f:p",
377
397
[
378
398
"all",
379
399
"extended",
400
+ "zfetch",
380
401
"outfile",
381
402
"help",
382
403
"verbose",
@@ -410,13 +431,15 @@ def init():
410
431
i += 1
411
432
if opt in ('-p', '--parsable'):
412
433
pretty_print = False
434
+ if opt in ('-z', '--zfetch'):
435
+ zflag = True
413
436
i += 1
414
437
415
438
argv = sys.argv[i:]
416
439
sint = int(argv[0]) if argv else sint
417
440
count = int(argv[1]) if len(argv) > 1 else (0 if len(argv) > 0 else 1)
418
441
419
- if hflag or (xflag and desired_cols):
442
+ if hflag or (xflag and zflag) or ((zflag or xflag) and desired_cols):
420
443
usage()
421
444
422
445
if vflag:
@@ -425,6 +448,9 @@ def init():
425
448
if xflag:
426
449
hdr = xhdr
427
450
451
+ if zflag:
452
+ hdr = zhdr
453
+
428
454
update_hdr_intr()
429
455
430
456
# check if L2ARC exists
@@ -569,6 +595,17 @@ def calculate():
569
595
v["el2mru"] = d["evict_l2_eligible_mru"] // sint
570
596
v["el2inel"] = d["evict_l2_ineligible"] // sint
571
597
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
572
609
573
610
if l2exist:
574
611
v["l2hits"] = d["l2_hits"] // sint
0 commit comments