public
Last active

OCaml SystemTap probes

  • Download Gist
gistfile1.txt
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
[nicolas@tau OCaml]$ cat demogc.ml
let main () =
let rec loop = function
| 0 -> ()
| n -> let _ = Array.make 1024 1 in
loop (n - 1)
in
loop 1024
;;
 
main ()
[nicolas@tau OCaml]$ ./4.00.1/bin/ocamlbuild demogc.native
Finished, 4 targets (0 cached) in 00:00:00.
 
[nicolas@tau OCaml]$ stap -L 'process("demogc.native").mark("*")'
process("demogc.native").mark("minor_collection__entry") $arg1:long
process("demogc.native").mark("minor_collection__return") $arg1:long
 
[nicolas@tau OCaml]$ cat gc.stp
probe process.provider("camlgc").mark("minor_collection__entry") {
printf("%s.%s: allocated words = %d\n", $$provider, $$name, $arg1);
}
 
probe process.provider("camlgc").mark("minor_collection__return") {
printf("%s.%s: promoted words = %d\n", $$provider, $$name, $arg1);
}
 
[nicolas@tau OCaml]$ stap -c ./demogc.native gc.stp
camlgc.minor_collection__entry: allocated words = 262409
camlgc.minor_collection__return: promoted words = 23
camlgc.minor_collection__entry: allocated words = 262400
camlgc.minor_collection__return: promoted words = 0
camlgc.minor_collection__entry: allocated words = 262400
camlgc.minor_collection__return: promoted words = 0
camlgc.minor_collection__entry: allocated words = 262400
camlgc.minor_collection__return: promoted words = 0
gistfile2.txt
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
nicolas@tau OCaml]$ cat demogc.ml
let main () =
let rec loop = function
| 0 -> ()
| n -> let _ = Array.make 1024 1 in
loop (n - 1)
in
loop 1024
;;
 
main ()
[nicolas@tau OCaml]$ ./4.00.1/bin/ocamlbuild demogc.native
Finished, 4 targets (0 cached) in 00:00:00.
 
[nicolas@tau OCaml]$ stap -L 'process("demogc.native").mark("*")' | grep Demogc
process("demogc.native").mark("camlDemogc__entry")
process("demogc.native").mark("camlDemogc__loop_1009")
process("demogc.native").mark("camlDemogc__main_1008")
 
[nicolas@tau OCaml]$ cat gc.stp
global loopcnt = 0
 
probe process.provider("camlgc").mark("minor_collection__entry") {
printf("Hit minor GC collection after %u loop iterations\n", loopcnt);
loopcnt = 0;
printf("%s.%s: allocated words = %d\n", $$provider, $$name, $arg1);
}
 
probe process.provider("camlgc").mark("minor_collection__return") {
printf("%s.%s: promoted words = %d\n", $$provider, $$name, $arg1);
}
 
probe process.provider("camlfun").mark("camlDemogc__loop_1009") {
loopcnt++;
}
 
[nicolas@tau OCaml]$ stap gc.stp -c ./demogc.native
Hit minor GC collection after 256 loop iterations
camlgc.minor_collection__entry: allocated words = 262409
camlgc.minor_collection__return: promoted words = 23
Hit minor GC collection after 256 loop iterations
camlgc.minor_collection__entry: allocated words = 262400
camlgc.minor_collection__return: promoted words = 0
Hit minor GC collection after 256 loop iterations
camlgc.minor_collection__entry: allocated words = 262400
camlgc.minor_collection__return: promoted words = 0
Hit minor GC collection after 256 loop iterations
camlgc.minor_collection__entry: allocated words = 262400
camlgc.minor_collection__return: promoted words = 0

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.