Back to home page

OSCL-LXR

 
 

    


0001 Overhead calculation
0002 --------------------
0003 The overhead can be shown in two columns as 'Children' and 'Self' when
0004 perf collects callchains.  The 'self' overhead is simply calculated by
0005 adding all period values of the entry - usually a function (symbol).
0006 This is the value that perf shows traditionally and sum of all the
0007 'self' overhead values should be 100%.
0008 
0009 The 'children' overhead is calculated by adding all period values of
0010 the child functions so that it can show the total overhead of the
0011 higher level functions even if they don't directly execute much.
0012 'Children' here means functions that are called from another (parent)
0013 function.
0014 
0015 It might be confusing that the sum of all the 'children' overhead
0016 values exceeds 100% since each of them is already an accumulation of
0017 'self' overhead of its child functions.  But with this enabled, users
0018 can find which function has the most overhead even if samples are
0019 spread over the children.
0020 
0021 Consider the following example; there are three functions like below.
0022 
0023 -----------------------
0024 void foo(void) {
0025     /* do something */
0026 }
0027 
0028 void bar(void) {
0029     /* do something */
0030     foo();
0031 }
0032 
0033 int main(void) {
0034     bar()
0035     return 0;
0036 }
0037 -----------------------
0038 
0039 In this case 'foo' is a child of 'bar', and 'bar' is an immediate
0040 child of 'main' so 'foo' also is a child of 'main'.  In other words,
0041 'main' is a parent of 'foo' and 'bar', and 'bar' is a parent of 'foo'.
0042 
0043 Suppose all samples are recorded in 'foo' and 'bar' only.  When it's
0044 recorded with callchains the output will show something like below
0045 in the usual (self-overhead-only) output of perf report:
0046 
0047 ----------------------------------
0048 Overhead  Symbol
0049 ........  .....................
0050   60.00%  foo
0051           |
0052           --- foo
0053               bar
0054               main
0055               __libc_start_main
0056 
0057   40.00%  bar
0058           |
0059           --- bar
0060               main
0061               __libc_start_main
0062 ----------------------------------
0063 
0064 When the --children option is enabled, the 'self' overhead values of
0065 child functions (i.e. 'foo' and 'bar') are added to the parents to
0066 calculate the 'children' overhead.  In this case the report could be
0067 displayed as:
0068 
0069 -------------------------------------------
0070 Children      Self  Symbol
0071 ........  ........  ....................
0072  100.00%     0.00%  __libc_start_main
0073           |
0074           --- __libc_start_main
0075 
0076  100.00%     0.00%  main
0077           |
0078           --- main
0079               __libc_start_main
0080 
0081  100.00%    40.00%  bar
0082           |
0083           --- bar
0084               main
0085               __libc_start_main
0086 
0087   60.00%    60.00%  foo
0088           |
0089           --- foo
0090               bar
0091               main
0092               __libc_start_main
0093 -------------------------------------------
0094 
0095 In the above output, the 'self' overhead of 'foo' (60%) was add to the
0096 'children' overhead of 'bar', 'main' and '\_\_libc_start_main'.
0097 Likewise, the 'self' overhead of 'bar' (40%) was added to the
0098 'children' overhead of 'main' and '\_\_libc_start_main'.
0099 
0100 So '\_\_libc_start_main' and 'main' are shown first since they have
0101 same (100%) 'children' overhead (even though they have zero 'self'
0102 overhead) and they are the parents of 'foo' and 'bar'.
0103 
0104 Since v3.16 the 'children' overhead is shown by default and the output
0105 is sorted by its values. The 'children' overhead is disabled by
0106 specifying --no-children option on the command line or by adding
0107 'report.children = false' or 'top.children = false' in the perf config
0108 file.