-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathspa_sync.d
executable file
·358 lines (309 loc) · 9.31 KB
/
spa_sync.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
#!/usr/sbin/dtrace -s
/* Copyright ClusterHQ Inc. See LICENSE file for details. */
#pragma D option quiet
#pragma D option defaultargs
#pragma D option bufsize=200m
#pragma D option dynvarsize=256m
#pragma D option cleanrate=5000hz
inline uint64_t TXG_MASK = 3;
struct spa_info {
spa_t *spa;
dmu_tx_t *tx;
int zio_wait;
uint64_t txg;
uint64_t tx_commit;
uint64_t misc_ts;
uint64_t start_time;
uint64_t prev_time;
uint64_t deferred;
uint64_t deferred_time;
uint64_t free;
uint64_t free_time;
uint64_t dsl_dataset_sync;
uint64_t dsl_dataset_sync_time;
uint64_t converged;
uint64_t dsl_pool_sync_count;
uint64_t dsl_pool_sync_time;
uint64_t dsl_pool_sync;
uint64_t vdev_sync_time;
uint64_t vdev_sync;
uint64_t dsl_dataset_sync2_time;
uint64_t dsl_dataset_sync2;
uint64_t dsl_sync_task_sync_time;
uint64_t dsl_sync_task_sync;
uint64_t dmu_objset_sync_time;
uint64_t dmu_objset_sync;
uint64_t dsl_dir_sync_time;
uint64_t dsl_dir_sync;
uint64_t ddt_sync_time;
uint64_t ddt_sync;
uint64_t dsl_scan_sync_time;
uint64_t dsl_scan_sync;
uint64_t stage;
};
struct spa_info spas[struct thread *];
fbt::spa_sync:entry
{
this->ts = timestamp;
this->thr = curthread;
spas[this->thr].spa = 0;
spas[this->thr].start_time = 0;
spas[this->thr].prev_time = 0;
spas[this->thr].deferred = 0;
spas[this->thr].deferred_time = 0;
spas[this->thr].zio_wait = 0;
spas[this->thr].txg = 0;
spas[this->thr].tx = 0;
spas[this->thr].misc_ts = 0;
spas[this->thr].tx_commit = 0;
spas[this->thr].free = 0;
spas[this->thr].free_time = 0;
spas[this->thr].dsl_dataset_sync = 0;
spas[this->thr].dsl_dataset_sync_time = 0;
spas[this->thr].converged = 0;
spas[this->thr].dsl_pool_sync_count = 0;
spas[this->thr].dsl_pool_sync_time = 0;
spas[this->thr].dsl_pool_sync = 0;
spas[this->thr].vdev_sync_time = 0;
spas[this->thr].vdev_sync = 0;
spas[this->thr].dsl_dataset_sync2_time = 0;
spas[this->thr].dsl_dataset_sync2 = 0;
spas[this->thr].dsl_sync_task_sync_time = 0;
spas[this->thr].dsl_sync_task_sync = 0;
spas[this->thr].dmu_objset_sync_time = 0;
spas[this->thr].dmu_objset_sync = 0;
spas[this->thr].dsl_dir_sync_time = 0;
spas[this->thr].dsl_dir_sync = 0;
spas[this->thr].ddt_sync_time = 0;
spas[this->thr].ddt_sync = 0;
spas[this->thr].dsl_scan_sync_time = 0;
spas[this->thr].dsl_scan_sync = 0;
spas[this->thr].stage = 0;
spas[this->thr].spa = args[0];
spas[this->thr].txg = args[1];
spas[this->thr].start_time = this->ts;
/*
@times[this->spa->spa_name, "idle"] = sum(this->ts - spas[this->thr].prev_time);
*/
/*
spas[this->thr].prev_time ? printf("idle time:\t%u\n", this->ts - spas[this->thr].prev_time) : (void)1;
*/
}
fbt::spa_sync:return
/spas[curthread].spa != 0/
{
this->ts = timestamp;
this->thr = curthread;
spas[this->thr].prev_time = this->ts;
this->spa = spas[this->thr].spa;
/*
@counts[this->spa->spa_name, "runs"] = count();
@times[this->spa->spa_name, "running"] = sum(this->ts - spas[this->thr].start_time);
*/
this->s = spas[this->thr].start_time;
this->total = this->ts - this->s;
printf("total running time:\t\t%d\n", this->total);
printf("\n");
printf("misc1 time:\t\t\t%d\n", spas[this->thr].misc_ts - this->s);
printf("\n");
printf("deferred freeing time:\t\t%d\n", spas[this->thr].deferred);
printf("\n");
printf("convergance passes:\t\t%d\n", spas[this->thr].dsl_pool_sync_count);
printf("total dsl_pool_sync time:\t%d\n", spas[this->thr].dsl_pool_sync_time);
printf("\tdatasets sync time:\t%d\n", spas[this->thr].dsl_dataset_sync2_time + spas[this->thr].dsl_dataset_sync_time);
printf("\tsynctask time:\t\t%d\n", spas[this->thr].dsl_sync_task_sync_time);
printf("\tmos time:\t\t%d\n", spas[this->thr].dmu_objset_sync_time);
printf("\tdsl dir time:\t\t%d\n", spas[this->thr].dsl_dir_sync_time);
printf("vdev sync time:\t\t\t%d\n", spas[this->thr].vdev_sync_time);
printf("\t(includes metaslab and spacemap processing)\n");
printf("ddt sync time:\t\t\t%d\n", spas[this->thr].ddt_sync_time);
printf("block freeing time:\t\t%d\n", spas[this->thr].free_time);
printf("dsl scan time:\t\t\t%d\n", spas[this->thr].dsl_scan_sync_time);
printf("\t(includes async destroy and deadlist processing time)\n");
printf("\n");
printf("total time to convergance:\t%d\n", spas[this->thr].converged - this->s);
printf("uberblock rewrite:\t\t%d\n", spas[this->thr].tx_commit - spas[this->thr].converged);
printf("misc2 time:\t\t\t%d\n", this->ts - spas[this->thr].tx_commit);
printf("\n----------------------------------------\n\n");
}
fbt::dmu_tx_create_assigned:return
/spas[curthread].spa != 0 && spas[curthread].tx == 0/
{
spas[curthread].misc_ts = timestamp;
spas[curthread].tx = (dmu_tx_t *)args[1];
}
fbt::dmu_tx_commit:entry
/spas[curthread].tx == args[0]/
{
spas[curthread].tx_commit = timestamp;
}
fbt::bpobj_iterate_impl:entry
/spas[curthread].spa != 0 &&
args[0] == &(spas[curthread].spa->spa_deferred_bpobj)/
{
spas[curthread].deferred = timestamp;
}
fbt::bpobj_iterate_impl:return
/spas[curthread].spa != 0 &&
spas[curthread].deferred != 0/
{
spas[curthread].zio_wait = 1;
}
fbt::zio_wait:return
/spas[curthread].spa != 0 &&
spas[curthread].zio_wait != 0 &&
spas[curthread].deferred > 0/
{
spas[curthread].deferred_time = timestamp - spas[curthread].deferred;
spas[curthread].zio_wait = 0;
spas[curthread].deferred = 0;
}
fbt::bplist_iterate:entry
/spas[curthread].spa != 0 &&
args[0] ==
&(spas[curthread].spa->spa_free_bplist[spas[curthread].txg & TXG_MASK])/
{
spas[curthread].free = timestamp;
spas[curthread].zio_wait = 1; /* XXX */
}
/*
fbt::bplist_iterate:return
/spas[curthread].spa != 0 &&
spas[curthread].free != 0/
{
spas[curthread].zio_wait = 1;
}
*/
fbt::zio_wait:return
/spas[curthread].spa != 0 &&
spas[curthread].zio_wait != 0 &&
spas[curthread].free > 0/
{
spas[curthread].free_time += timestamp - spas[curthread].free;
spas[curthread].zio_wait = 0;
spas[curthread].free > 0;
}
fbt::dsl_pool_sync:entry
/spas[curthread].spa != 0/
{
spas[curthread].dsl_pool_sync = timestamp;
spas[curthread].stage = 1;
}
fbt::dsl_pool_sync:return
/spas[curthread].dsl_pool_sync != 0/
{
spas[curthread].dsl_pool_sync_time += timestamp - spas[curthread].dsl_pool_sync;
spas[curthread].dsl_pool_sync_count++;
spas[curthread].stage = 0;
spas[curthread].dsl_pool_sync = 0;
}
fbt::vdev_sync:entry
/spas[curthread].spa != 0/
{
spas[curthread].vdev_sync = timestamp;
}
fbt::txg_list_add:entry
/spas[curthread].vdev_sync != 0 && args[0] == &spas[curthread].spa->spa_vdev_txg_list/
{
spas[curthread].vdev_sync_time += timestamp - spas[curthread].vdev_sync;
spas[curthread].vdev_sync = 0;
}
fbt::ddt_sync:entry
/spas[curthread].spa != 0/
{
spas[curthread].ddt_sync = timestamp;
}
fbt::ddt_sync:return
/spas[curthread].ddt_sync != 0/
{
spas[curthread].ddt_sync_time += timestamp - spas[curthread].ddt_sync;
}
fbt::dsl_scan_sync:entry
/spas[curthread].spa != 0/
{
spas[curthread].dsl_scan_sync = timestamp;
}
fbt::dsl_scan_sync:return
/spas[curthread].dsl_scan_sync != 0/
{
spas[curthread].dsl_scan_sync_time += timestamp - spas[curthread].dsl_scan_sync;
}
fbt::dmu_objset_is_dirty:return
/spas[curthread].spa != 0 && arg1 == 0/
{
spas[curthread].converged = timestamp;
}
/* ============================= */
fbt::zio_root:entry
/spas[curthread].dsl_pool_sync != 0 && args[0] == spas[curthread].spa &&
spas[curthread].stage == 1/
{
spas[curthread].dsl_dataset_sync = timestamp;
}
fbt::zio_wait:return
/spas[curthread].dsl_pool_sync != 0 &&
spas[curthread].stage == 1 && spas[curthread].dsl_dataset_sync != 0/
{
spas[curthread].dsl_dataset_sync_time += timestamp - spas[curthread].dsl_dataset_sync;
spas[curthread].dsl_dataset_sync = 0;
spas[curthread].stage++;
}
fbt::zio_root:entry
/spas[curthread].dsl_pool_sync != 0 && args[0] == spas[curthread].spa &&
spas[curthread].stage == 2/
{
spas[curthread].dsl_dataset_sync2 = timestamp;
}
fbt::zio_wait:return
/spas[curthread].dsl_pool_sync != 0 &&
spas[curthread].stage == 2 && spas[curthread].dsl_dataset_sync2 != 0/
{
spas[curthread].dsl_dataset_sync2_time += timestamp - spas[curthread].dsl_dataset_sync2;
spas[curthread].dsl_dataset_sync2 = 0;
spas[curthread].stage++;
}
fbt::dsl_dir_sync:entry
/spas[curthread].spa != 0 && spas[curthread].stage == 3/
{
spas[curthread].dsl_dir_sync = timestamp;
}
fbt::txg_list_remove:return
/spas[curthread].spa != 0 && spas[curthread].stage == 3 &&
spas[curthread].dsl_dir_sync != 0 && arg1 == 0/
{
spas[curthread].dsl_dir_sync_time += timestamp - spas[curthread].dsl_dir_sync;
spas[curthread].dsl_dir_sync = 0;
}
fbt::zio_root:entry
/spas[curthread].dsl_pool_sync != 0 && args[0] == spas[curthread].spa &&
spas[curthread].stage == 3/
{
spas[curthread].dmu_objset_sync = timestamp;
}
fbt::zio_wait:return
/spas[curthread].dsl_pool_sync != 0 &&
spas[curthread].stage == 3 && spas[curthread].dmu_objset_sync != 0/
{
spas[curthread].dmu_objset_sync_time += timestamp - spas[curthread].dmu_objset_sync;
spas[curthread].dmu_objset_sync = 0;
spas[curthread].stage++;
}
fbt::dsl_sync_task_sync:entry
/spas[curthread].spa != 0 && spas[curthread].stage == 4/
{
spas[curthread].dsl_sync_task_sync = timestamp;
}
fbt::dsl_sync_task_sync:return
/spas[curthread].spa != 0 && spas[curthread].stage == 4/
{
spas[curthread].dsl_sync_task_sync_time += timestamp - spas[curthread].dsl_sync_task_sync;
spas[curthread].stage++;
}
/* ============================= */
/*
profile:::tick-1sec
{
printa(@counts);
printa(@times);
}
*/