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