xref: /illumos-gate/usr/src/test/zfs-tests/tests/perf/scripts/prefetch_io.d (revision 8a2b682e57a046b828f37bcde1776f131ef4629f)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright (c) 2015, 2016 by Delphix. All rights reserved.
14  */
15 
16 /*
17  * prefetch_ios: Number of IOs the prefetcher issued
18  * @c["prefetched_demand_reads"]: Number of demand reads already prefetched
19  * @c["sync_wait_for_async"]: Number of times sync IO waited for prefetch IO
20  * @s["demand"]: Number of non-prefetch read IOs
21  * @s["logical"]: Logical (uncompressed) bytes read per interval
22  * @s["physical"]: Physical (compressed) bytes read per interval
23  */
24 
25 #pragma D option aggsortkey
26 #pragma D option quiet
27 
28 #define	SPA_MINBLOCKSHIFT	9
29 #define	ARC_FLAGS_PREFETCH	(1 << 3)
30 #define	HDR_GET_LSIZE(hdr)	((hdr)->b_lsize << SPA_MINBLOCKSHIFT)
31 #define	HDR_GET_PSIZE(hdr)	((hdr)->b_psize << SPA_MINBLOCKSHIFT)
32 
33 BEGIN
34 {
35 	prefetch_ios = `arc_stats.arcstat_prefetch_data_misses.value.ui64;
36 	prefetch_ios += `arc_stats.arcstat_prefetch_metadata_misses.value.ui64;
37 	@s["demand"] = sum(0);
38 	@s["logical"] = sum(0);
39 	@s["physical"] = sum(0);
40 	@c["prefetched_demand_reads"] = count();
41 	@c["sync_wait_for_async"] = count();
42 	clear(@s);
43 	clear(@c);
44 }
45 
46 arc_read:arc-demand-hit-predictive-prefetch
47 {
48 	@c["prefetched_demand_reads"] = count();
49 }
50 
51 arc_read:arc-upgrade-sync
52 {
53 	@c["async_upgrade_sync"] = count();
54 }
55 
56 arc_read_done:entry
57 / args[0]->io_spa->spa_name == $$1 /
58 {
59 	this->zio = args[0];
60 	this->hdr = (arc_buf_hdr_t *)this->zio->io_private;
61 	@s["demand"] = sum(this->hdr->b_flags & ARC_FLAGS_PREFETCH ? 0 : 1);
62 	@s["logical"] = sum(HDR_GET_LSIZE(this->hdr));
63 	@s["physical"] = sum(HDR_GET_PSIZE(this->hdr));
64 }
65 
66 tick-$2s
67 {
68 	this->new_prefetch_ios =
69 	    `arc_stats.arcstat_prefetch_data_misses.value.ui64 +
70 	    `arc_stats.arcstat_prefetch_metadata_misses.value.ui64;
71 	printf("%u\n%-24s\t%u\n", `time, "prefetch_ios",
72 	    this->new_prefetch_ios - prefetch_ios);
73 	printa("%-24s\t%@u\n", @s);
74 	printa("%-24s\t%@u\n", @c);
75 	prefetch_ios = this->new_prefetch_ios;
76 	clear(@s);
77 	clear(@c);
78 }
79 
80 ERROR
81 {
82 	trace(arg1);
83 	trace(arg2);
84 	trace(arg3);
85 	trace(arg4);
86 	trace(arg5);
87 }
88