Home | History | Annotate | Download | only in tools
      1 Demonstrations of uobjnew.
      2 
      3 
      4 uobjnew summarizes new object allocation events and prints out statistics on
      5 which object type has been allocated frequently, and how many bytes of that
      6 type have been allocated. This helps diagnose common allocation paths, which
      7 can in turn cause heavy garbage collection.
      8 
      9 For example, trace Ruby object allocations when running some simple commands
     10 in irb (the Ruby REPL):
     11 
     12 # ./uobjnew -l ruby 27245
     13 Tracing allocations in process 27245 (language: ruby)... Ctrl-C to quit.
     14 
     15 TYPE                           # ALLOCS      # BYTES
     16 NameError                             1            0
     17 RubyToken::TkSPACE                    1            0
     18 RubyToken::TkSTRING                   1            0
     19 String                                7            0
     20 RubyToken::TkNL                       2            0
     21 RubyToken::TkIDENTIFIER               2            0
     22 array                                55          129
     23 string                              344         1348
     24 ^C
     25 
     26 
     27 Plain C/C++ allocations (through "malloc") are also supported. We can't report
     28 the type being allocated, but we can report the object sizes at least. Also,
     29 print only the top 10 rows by number of bytes allocated:
     30 
     31 # ./uobjnew -S 10 -l c 27245
     32 Tracing allocations in process 27245 (language: c)... Ctrl-C to quit.
     33 
     34 TYPE                           # ALLOCS      # BYTES
     35 block size 64                        22         1408
     36 block size 992                        2         1984
     37 block size 32                        68         2176
     38 block size 48                        48         2304
     39 block size 944                        4         3776
     40 block size 1104                       4         4416
     41 block size 160                       32         5120
     42 block size 535                       15         8025
     43 block size 128                      112        14336
     44 block size 80                       569        45520
     45 ^C
     46 
     47 
     48 USAGE message:
     49 
     50 # ./uobjnew -h
     51 usage: uobjnew.py [-h] [-l {c,java,ruby,tcl}] [-C TOP_COUNT] [-S TOP_SIZE] [-v]
     52                   pid [interval]
     53 
     54 Summarize object allocations in high-level languages.
     55 
     56 positional arguments:
     57   pid                   process id to attach to
     58   interval              print every specified number of seconds
     59 
     60 optional arguments:
     61   -h, --help            show this help message and exit
     62   -l {c,java,ruby,tcl}, --language {c,java,ruby,tcl}
     63                         language to trace
     64   -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 
     71 examples:
     72     ./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
     76