blob: fcb2d2177ebd1277aa3018965700c9ebb3197fcf [file] [log] [blame]
Sasha Goldshtein7160f8a2016-10-29 13:33:24 -07001Demonstrations of uobjnew.
2
3
4uobjnew summarizes new object allocation events and prints out statistics on
5which object type has been allocated frequently, and how many bytes of that
6type have been allocated. This helps diagnose common allocation paths, which
7can in turn cause heavy garbage collection.
8
9For example, trace Ruby object allocations when running some simple commands
10in irb (the Ruby REPL):
11
Paul Chaignon4bb6d7f2017-03-30 19:05:40 +020012# ./uobjnew -l ruby 27245
Sasha Goldshtein7160f8a2016-10-29 13:33:24 -070013Tracing allocations in process 27245 (language: ruby)... Ctrl-C to quit.
14
15TYPE # ALLOCS # BYTES
16NameError 1 0
17RubyToken::TkSPACE 1 0
18RubyToken::TkSTRING 1 0
19String 7 0
20RubyToken::TkNL 2 0
21RubyToken::TkIDENTIFIER 2 0
22array 55 129
23string 344 1348
24^C
25
26
27Plain C/C++ allocations (through "malloc") are also supported. We can't report
28the type being allocated, but we can report the object sizes at least. Also,
29print only the top 10 rows by number of bytes allocated:
30
Paul Chaignon4bb6d7f2017-03-30 19:05:40 +020031# ./uobjnew -S 10 -l c 27245
Sasha Goldshtein7160f8a2016-10-29 13:33:24 -070032Tracing allocations in process 27245 (language: c)... Ctrl-C to quit.
33
34TYPE # ALLOCS # BYTES
35block size 64 22 1408
36block size 992 2 1984
37block size 32 68 2176
38block size 48 48 2304
39block size 944 4 3776
40block size 1104 4 4416
41block size 160 32 5120
42block size 535 15 8025
43block size 128 112 14336
44block size 80 569 45520
45^C
46
47
48USAGE message:
49
50# ./uobjnew -h
Marko Myllynen9f3662e2018-10-10 21:48:53 +030051usage: uobjnew.py [-h] [-l {c,java,ruby,tcl}] [-C TOP_COUNT] [-S TOP_SIZE] [-v]
Paul Chaignon4bb6d7f2017-03-30 19:05:40 +020052 pid [interval]
Sasha Goldshtein7160f8a2016-10-29 13:33:24 -070053
54Summarize object allocations in high-level languages.
55
56positional arguments:
Sasha Goldshtein7160f8a2016-10-29 13:33:24 -070057 pid process id to attach to
58 interval print every specified number of seconds
59
60optional arguments:
61 -h, --help show this help message and exit
Marko Myllynen9f3662e2018-10-10 21:48:53 +030062 -l {c,java,ruby,tcl}, --language {c,java,ruby,tcl}
Paul Chaignon4bb6d7f2017-03-30 19:05:40 +020063 language to trace
Sasha Goldshtein7160f8a2016-10-29 13:33:24 -070064 -C TOP_COUNT, --top-count TOP_COUNT
65 number of most frequently allocated types to print
66 -S TOP_SIZE, --top-size TOP_SIZE
67 number of largest types by allocated bytes to print
68 -v, --verbose verbose mode: print the BPF program (for debugging
69 purposes)
70
71examples:
Paul Chaignon4bb6d7f2017-03-30 19:05:40 +020072 ./uobjnew -l java 145 # summarize Java allocations in process 145
73 ./uobjnew -l c 2020 1 # grab malloc() sizes and print every second
74 ./uobjnew -l ruby 6712 -C 10 # top 10 Ruby types by number of allocations
75 ./uobjnew -l ruby 6712 -S 10 # top 10 Ruby types by total size