xref: /illumos-gate/usr/src/test/zfs-tests/tests/perf/scripts/prefetch_io.d (revision dcbf3bd6a1f1360fc1afcee9e22c6dcff7844bf2)
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 by Delphix. All rights reserved.
16  */
17 
18 /*
19  * prefetch_ios: Number of IOs the prefetcher issued
20  * @pf["prefetched_demand_reads"]: Number of demand reads already prefetched
21  * @pf["sync_wait_for_async"]: Number of times sync IO waited for prefetch IO
22  * @pf["demand"]: Number of non-prefetch read IOs
23  * @pf["logical"]: Logical (uncompressed) bytes read per interval
24  * @pf["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 	@pf["demand"] = sum(0);
40 	@pf["logical"] = sum(0);
41 	@pf["physical"] = sum(0);
42 	@pf["prefetched_demand_reads"] = count();
43 	@pf["sync_wait_for_async"] = count();
44 	clear(@pf);
45 }
46 
47 arc_read:arc-demand-hit-predictive-prefetch
48 {
49 	@pf["prefetched_demand_reads"] = count();
50 }
51 
52 arc_read:arc-sync-wait-for-async
53 {
54 	@pf["sync_wait_for_async"] = count();
55 }
56 
57 arc_read_done:entry
58 / args[0]->io_spa->spa_name == $$1 /
59 {
60 	this->zio = args[0];
61 	this->buf = (arc_buf_t *)this->zio->io_private;
62 	this->hdr = this->buf->b_hdr;
63 	@pf["demand"] = sum(this->hdr->b_flags & ARC_FLAGS_PREFETCH ? 0 : 1);
64 	@pf["logical"] = sum(HDR_GET_LSIZE(this->hdr));
65 	@pf["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", @pf);
76 	prefetch_ios = this->new_prefetch_ios;
77 	clear(@pf);
78 }
79 
80 ERROR
81 {
82 	trace(arg1);
83 	trace(arg2);
84 	trace(arg3);
85 	trace(arg4);
86 	trace(arg5);
87 }
88