You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
3.0 KiB
76 lines
3.0 KiB
Demonstrations of uobjnew.
|
|
|
|
|
|
uobjnew summarizes new object allocation events and prints out statistics on
|
|
which object type has been allocated frequently, and how many bytes of that
|
|
type have been allocated. This helps diagnose common allocation paths, which
|
|
can in turn cause heavy garbage collection.
|
|
|
|
For example, trace Ruby object allocations when running some simple commands
|
|
in irb (the Ruby REPL):
|
|
|
|
# ./uobjnew -l ruby 27245
|
|
Tracing allocations in process 27245 (language: ruby)... Ctrl-C to quit.
|
|
|
|
TYPE # ALLOCS # BYTES
|
|
NameError 1 0
|
|
RubyToken::TkSPACE 1 0
|
|
RubyToken::TkSTRING 1 0
|
|
String 7 0
|
|
RubyToken::TkNL 2 0
|
|
RubyToken::TkIDENTIFIER 2 0
|
|
array 55 129
|
|
string 344 1348
|
|
^C
|
|
|
|
|
|
Plain C/C++ allocations (through "malloc") are also supported. We can't report
|
|
the type being allocated, but we can report the object sizes at least. Also,
|
|
print only the top 10 rows by number of bytes allocated:
|
|
|
|
# ./uobjnew -S 10 -l c 27245
|
|
Tracing allocations in process 27245 (language: c)... Ctrl-C to quit.
|
|
|
|
TYPE # ALLOCS # BYTES
|
|
block size 64 22 1408
|
|
block size 992 2 1984
|
|
block size 32 68 2176
|
|
block size 48 48 2304
|
|
block size 944 4 3776
|
|
block size 1104 4 4416
|
|
block size 160 32 5120
|
|
block size 535 15 8025
|
|
block size 128 112 14336
|
|
block size 80 569 45520
|
|
^C
|
|
|
|
|
|
USAGE message:
|
|
|
|
# ./uobjnew -h
|
|
usage: uobjnew.py [-h] [-l {c,java,ruby,tcl}] [-C TOP_COUNT] [-S TOP_SIZE] [-v]
|
|
pid [interval]
|
|
|
|
Summarize object allocations in high-level languages.
|
|
|
|
positional arguments:
|
|
pid process id to attach to
|
|
interval print every specified number of seconds
|
|
|
|
optional arguments:
|
|
-h, --help show this help message and exit
|
|
-l {c,java,ruby,tcl}, --language {c,java,ruby,tcl}
|
|
language to trace
|
|
-C TOP_COUNT, --top-count TOP_COUNT
|
|
number of most frequently allocated types to print
|
|
-S TOP_SIZE, --top-size TOP_SIZE
|
|
number of largest types by allocated bytes to print
|
|
-v, --verbose verbose mode: print the BPF program (for debugging
|
|
purposes)
|
|
|
|
examples:
|
|
./uobjnew -l java 145 # summarize Java allocations in process 145
|
|
./uobjnew -l c 2020 1 # grab malloc() sizes and print every second
|
|
./uobjnew -l ruby 6712 -C 10 # top 10 Ruby types by number of allocations
|
|
./uobjnew -l ruby 6712 -S 10 # top 10 Ruby types by total size
|