Project

General

Profile

Bug #9629 ยป trace-gc-standalone.sh

benweint (Ben Weintraub), 03/13/2014 12:31 AM

 
1
#!/bin/bash
2

    
3
PID=$1
4

    
5
cat > /tmp/dtracetmp.$$ <<EOF
6
#!/usr/sbin/dtrace -s
7

    
8
#pragma D option bufsize=16m
9
#pragma D option dynvarsize=16m
10
#pragma D option cleanrate=50Hz
11

    
12
BEGIN {
13
  printf("Ready! (Go press enter on the original script.)\n");
14
}
15

    
16
ruby${PID}:::gc-mark-begin {
17
  self->mark_begin = timestamp;
18
}
19

    
20
ruby${PID}:::gc-mark-end /self->mark_begin/ {
21
  elapsed = timestamp - self->mark_begin;
22
  @mark_total = sum(elapsed);
23
  @total = sum(elapsed);
24
  self->mark_begin = 0;
25
}
26

    
27
ruby${PID}:::gc-sweep-begin {
28
  self->sweep_begin = timestamp;
29
}
30

    
31
ruby${PID}:::gc-sweep-end /self->sweep_begin/ {
32
  elapsed = timestamp - self->sweep_begin;
33
  @sweep_total = sum(elapsed);
34
  @total = sum(elapsed);
35
  self->sweep_begin = 0;
36
}
37

    
38
END {
39
  normalize(@mark_total,  1000000);
40
  normalize(@sweep_total, 1000000);
41
  normalize(@total,       1000000);
42
  printa("Mark total:         %@d ms\n", @mark_total);
43
  printa("Sweep total:        %@d ms\n", @sweep_total);
44
  printa("Mark + sweep total: %@d ms\n", @total)
45
}
46

    
47
EOF
48

    
49
dtrace -q -s /tmp/dtracetmp.$$ -p $PID