[Asterisk-Dev] Asterisk CPU usage 99% profiling problem

Andres Maduro andres at iconos.com.ve
Tue May 31 16:38:45 MST 2005


Hi, 

I was able to compile with DEBUG=-g -pg, in order to be able for * to load, I had to recompile without -O6 optimization.

I ran for 2-3 minutes with an achieve a load of 99% with 4-5 simultaneous calls.

When I did gprof asterisk it did not show any times although it showed the functions being called.

It is my opinion that maybe the problem could be in the linear2alaw or alaw2linear code ?

Please have a look at the output.  I do not know if this could help.  If you have suggestions in how I should perform this test to gather more data, please tell me...

[root at asterisk1 sbin]# gprof asterisk 
Flat profile:

Each sample counts as 0.01 seconds.
 no time accumulated

  %   cumulative   self              self     total           
 time   seconds   seconds    calls  Ts/call  Ts/call  name    
  0.00      0.00     0.00    65536     0.00     0.00  linear2alaw
  0.00      0.00     0.00    65536     0.00     0.00  linear2ulaw
  0.00      0.00     0.00      401     0.00     0.00  ast_all_zeros
  0.00      0.00     0.00      256     0.00     0.00  alaw2linear
  0.00      0.00     0.00      203     0.00     0.00  ast_el_add_history
  0.00      0.00     0.00       45     0.00     0.00  ast_strlen_zero
  0.00      0.00     0.00       22     0.00     0.00  strip
  0.00      0.00     0.00       14     0.00     0.00  ast_el_read_char
  0.00      0.00     0.00       12     0.00     0.00  fix_header
  0.00      0.00     0.00        8     0.00     0.00  cfg_process
  0.00      0.00     0.00        6     0.00     0.00  ast_log
  0.00      0.00     0.00        6     0.00     0.00  ast_verbose
  0.00      0.00     0.00        5     0.00     0.00  join2
  0.00      0.00     0.00        4     0.00     0.00  ast_strlen_zero
  0.00      0.00     0.00        4     0.00     0.00  cli_prompt
  0.00      0.00     0.00        4     0.00     0.00  console_verboser
  0.00      0.00     0.00        3     0.00     0.00  ast_cli_register
  0.00      0.00     0.00        3     0.00     0.00  find_cli
  0.00      0.00     0.00        2     0.00     0.00  __ast_load
  0.00      0.00     0.00        2     0.00     0.00  ast_el_read_history
  0.00      0.00     0.00        2     0.00     0.00  ast_load
  0.00      0.00     0.00        2     0.00     0.00  ast_variable_browse
  0.00      0.00     0.00        2     0.00     0.00  fdprint
  0.00      0.00     0.00        2     0.00     0.00  term_quit
  0.00      0.00     0.00        1     0.00     0.00  ast_active_channels
  0.00      0.00     0.00        1     0.00     0.00  ast_alaw_init
  0.00      0.00     0.00        1     0.00     0.00  ast_destroy
  0.00      0.00     0.00        1     0.00     0.00  ast_el_initialize
  0.00      0.00     0.00        1     0.00     0.00  ast_el_write_history
  0.00      0.00     0.00        1     0.00     0.00  ast_readconfig
  0.00      0.00     0.00        1     0.00     0.00  ast_register_verbose
  0.00      0.00     0.00        1     0.00     0.00  ast_remotecontrol
  0.00      0.00     0.00        1     0.00     0.00  ast_run_atexits
  0.00      0.00     0.00        1     0.00     0.00  ast_tryconnect
  0.00      0.00     0.00        1     0.00     0.00  ast_ulaw_init
  0.00      0.00     0.00        1     0.00     0.00  ast_utils_init
  0.00      0.00     0.00        1     0.00     0.00  base64_init
  0.00      0.00     0.00        1     0.00     0.00  callerid_init
  0.00      0.00     0.00        1     0.00     0.00  clear_cust_keywords
  0.00      0.00     0.00        1     0.00     0.00  close_logger
  0.00      0.00     0.00        1     0.00     0.00  get_config_registrations
  0.00      0.00     0.00        1     0.00     0.00  manager_event
  0.00      0.00     0.00        1     0.00     0.00  quit_handler
  0.00      0.00     0.00        1     0.00     0.00  read_ast_cust_config
  0.00      0.00     0.00        1     0.00     0.00  register_config_cli
  0.00      0.00     0.00        1     0.00     0.00  remoteconsolehandler
  0.00      0.00     0.00        1     0.00     0.00  set_priority
  0.00      0.00     0.00        1     0.00     0.00  tdd_init
  0.00      0.00     0.00        1     0.00     0.00  term_end
  0.00      0.00     0.00        1     0.00     0.00  term_init

 %         the percentage of the total running time of the
time       program used by this function.

cumulative a running sum of the number of seconds accounted
 seconds   for by this function and those listed above it.

 self      the number of seconds accounted for by this
seconds    function alone.  This is the major sort for this
           listing.

calls      the number of times this function was invoked, if
           this function is profiled, else blank.
 
 self      the average number of milliseconds spent in this
ms/call    function per call, if this function is profiled,
           else blank.

 total     the average number of milliseconds spent in this
ms/call    function and its descendents per call, if this 
           function is profiled, else blank.

name       the name of the function.  This is the minor sort
           for this listing. The index shows the location of
           the function in the gprof listing. If the index is
           in parenthesis it shows where it would appear in
           the gprof listing if it were to be printed.


                     Call graph (explanation follows)


granularity: each sample hit covers 4 byte(s) no time propagated

index % time    self  children    called     name
                0.00    0.00   65536/65536       ast_alaw_init [25]
[1]      0.0    0.00    0.00   65536         linear2alaw [1]
-----------------------------------------------
                0.00    0.00   65536/65536       ast_ulaw_init [34]
[2]      0.0    0.00    0.00   65536         linear2ulaw [2]
-----------------------------------------------
                0.00    0.00       1/401         remoteconsolehandler [45]
                0.00    0.00     400/401         ast_el_read_history [19]
[3]      0.0    0.00    0.00     401         ast_all_zeros [3]
-----------------------------------------------
                0.00    0.00     256/256         ast_alaw_init [25]
[4]      0.0    0.00    0.00     256         alaw2linear [4]
-----------------------------------------------
                0.00    0.00       1/203         remoteconsolehandler [45]
                0.00    0.00     202/203         ast_el_read_history [19]
[5]      0.0    0.00    0.00     203         ast_el_add_history [5]
-----------------------------------------------
                0.00    0.00       8/45          cfg_process [10]
                0.00    0.00      37/45          strip [7]
[6]      0.0    0.00    0.00      45         ast_strlen_zero [6]
-----------------------------------------------
                0.00    0.00      22/22          cfg_process [10]
[7]      0.0    0.00    0.00      22         strip [7]
                0.00    0.00      37/45          ast_strlen_zero [6]
-----------------------------------------------
                0.00    0.00      14/14          el_getc [711]
[8]      0.0    0.00    0.00      14         ast_el_read_char [8]
                0.00    0.00       1/1           quit_handler [42]
-----------------------------------------------
                0.00    0.00      12/12          console_verboser [16]
[9]      0.0    0.00    0.00      12         fix_header [9]
-----------------------------------------------
                0.00    0.00       8/8           __ast_load [1258]
[10]     0.0    0.00    0.00       8         cfg_process [10]
                0.00    0.00      22/22          strip [7]
                0.00    0.00       8/45          ast_strlen_zero [6]
-----------------------------------------------
                0.00    0.00       6/6           ast_verbose [12]
[11]     0.0    0.00    0.00       6         ast_log [11]
-----------------------------------------------
                0.00    0.00       1/6           ast_remotecontrol [31]
                0.00    0.00       5/6           main [924]
[12]     0.0    0.00    0.00       6         ast_verbose [12]
                0.00    0.00       6/6           ast_log [11]
                0.00    0.00       4/4           console_verboser [16]
-----------------------------------------------
                0.00    0.00       5/5           ast_cli_register [17]
[13]     0.0    0.00    0.00       5         join2 [13]
-----------------------------------------------
                0.00    0.00       1/4           quit_handler [42]
                0.00    0.00       1/4           main [924]
                0.00    0.00       2/4           ast_remotecontrol [31]
[14]     0.0    0.00    0.00       4         ast_strlen_zero [14]
-----------------------------------------------
                0.00    0.00       4/4           prompt_print [1053]
[15]     0.0    0.00    0.00       4         cli_prompt [15]
-----------------------------------------------
                0.00    0.00       4/4           ast_verbose [12]
[16]     0.0    0.00    0.00       4         console_verboser [16]
                0.00    0.00      12/12          fix_header [9]
-----------------------------------------------
                0.00    0.00       1/3           register_config_cli [44]
                0.00    0.00       2/3           ast_remotecontrol [31]
[17]     0.0    0.00    0.00       3         ast_cli_register [17]
                0.00    0.00       5/5           join2 [13]
                0.00    0.00       3/3           find_cli [18]
-----------------------------------------------
                0.00    0.00       3/3           ast_cli_register [17]
[18]     0.0    0.00    0.00       3         find_cli [18]
-----------------------------------------------
                0.00    0.00       1/2           ast_remotecontrol [31]
                0.00    0.00       1/2           main [924]
[19]     0.0    0.00    0.00       2         ast_el_read_history [19]
                0.00    0.00     400/401         ast_all_zeros [3]
                0.00    0.00     202/203         ast_el_add_history [5]
-----------------------------------------------
                0.00    0.00       1/2           read_ast_cust_config [43]
                0.00    0.00       1/2           ast_readconfig [29]
[20]     0.0    0.00    0.00       2         ast_load [20]
                0.00    0.00       2/2           __ast_load [1258]
-----------------------------------------------
                0.00    0.00       2/2           ast_readconfig [29]
[21]     0.0    0.00    0.00       2         ast_variable_browse [21]
-----------------------------------------------
                0.00    0.00       2/2           ast_remotecontrol [31]
[22]     0.0    0.00    0.00       2         fdprint [22]
-----------------------------------------------
                0.00    0.00       1/2           quit_handler [42]
                0.00    0.00       1/2           main [924]
[23]     0.0    0.00    0.00       2         term_quit [23]
-----------------------------------------------
                0.00    0.00       1/1           quit_handler [42]
[24]     0.0    0.00    0.00       1         ast_active_channels [24]
-----------------------------------------------
                0.00    0.00       1/1           main [924]
[25]     0.0    0.00    0.00       1         ast_alaw_init [25]
                0.00    0.00   65536/65536       linear2alaw [1]
                0.00    0.00     256/256         alaw2linear [4]
-----------------------------------------------
                0.00    0.00       1/1           ast_readconfig [29]
[26]     0.0    0.00    0.00       1         ast_destroy [26]
-----------------------------------------------
                0.00    0.00       1/1           main [924]
[27]     0.0    0.00    0.00       1         ast_el_initialize [27]
-----------------------------------------------
                0.00    0.00       1/1           quit_handler [42]
[28]     0.0    0.00    0.00       1         ast_el_write_history [28]
-----------------------------------------------
                0.00    0.00       1/1           main [924]
[29]     0.0    0.00    0.00       1         ast_readconfig [29]
                0.00    0.00       2/2           ast_variable_browse [21]
                0.00    0.00       1/2           ast_load [20]
                0.00    0.00       1/1           ast_destroy [26]
-----------------------------------------------
                0.00    0.00       1/1           main [924]
[30]     0.0    0.00    0.00       1         ast_register_verbose [30]
-----------------------------------------------
                0.00    0.00       1/1           main [924]
[31]     0.0    0.00    0.00       1         ast_remotecontrol [31]
                0.00    0.00       2/2           fdprint [22]
                0.00    0.00       2/4           ast_strlen_zero [14]
                0.00    0.00       2/3           ast_cli_register [17]
                0.00    0.00       1/6           ast_verbose [12]
                0.00    0.00       1/2           ast_el_read_history [19]
                0.00    0.00       1/1           remoteconsolehandler [45]
-----------------------------------------------
                0.00    0.00       1/1           quit_handler [42]
[32]     0.0    0.00    0.00       1         ast_run_atexits [32]
-----------------------------------------------
                0.00    0.00       1/1           main [924]
[33]     0.0    0.00    0.00       1         ast_tryconnect [33]
-----------------------------------------------
                0.00    0.00       1/1           main [924]
[34]     0.0    0.00    0.00       1         ast_ulaw_init [34]
                0.00    0.00   65536/65536       linear2ulaw [2]
-----------------------------------------------
                0.00    0.00       1/1           main [924]
[35]     0.0    0.00    0.00       1         ast_utils_init [35]
                0.00    0.00       1/1           base64_init [36]
-----------------------------------------------
                0.00    0.00       1/1           ast_utils_init [35]
[36]     0.0    0.00    0.00       1         base64_init [36]
-----------------------------------------------
                0.00    0.00       1/1           main [924]
[37]     0.0    0.00    0.00       1         callerid_init [37]
-----------------------------------------------
                0.00    0.00       1/1           read_ast_cust_config [43]
[38]     0.0    0.00    0.00       1         clear_cust_keywords [38]
                0.00    0.00       1/1           get_config_registrations [40]
-----------------------------------------------
                0.00    0.00       1/1           quit_handler [42]
[39]     0.0    0.00    0.00       1         close_logger [39]
-----------------------------------------------
                0.00    0.00       1/1           clear_cust_keywords [38]
[40]     0.0    0.00    0.00       1         get_config_registrations [40]
-----------------------------------------------
                0.00    0.00       1/1           quit_handler [42]
[41]     0.0    0.00    0.00       1         manager_event [41]
-----------------------------------------------
                0.00    0.00       1/1           ast_el_read_char [8]
[42]     0.0    0.00    0.00       1         quit_handler [42]
                0.00    0.00       1/4           ast_strlen_zero [14]
                0.00    0.00       1/1           ast_el_write_history [28]
                0.00    0.00       1/1           ast_run_atexits [32]
                0.00    0.00       1/1           ast_active_channels [24]
                0.00    0.00       1/1           manager_event [41]
                0.00    0.00       1/2           term_quit [23]
                0.00    0.00       1/1           close_logger [39]
-----------------------------------------------
                0.00    0.00       1/1           main [924]
[43]     0.0    0.00    0.00       1         read_ast_cust_config [43]
                0.00    0.00       1/1           clear_cust_keywords [38]
                0.00    0.00       1/2           ast_load [20]
-----------------------------------------------
                0.00    0.00       1/1           main [924]
[44]     0.0    0.00    0.00       1         register_config_cli [44]
                0.00    0.00       1/3           ast_cli_register [17]
-----------------------------------------------
                0.00    0.00       1/1           ast_remotecontrol [31]
[45]     0.0    0.00    0.00       1         remoteconsolehandler [45]
                0.00    0.00       1/401         ast_all_zeros [3]
                0.00    0.00       1/203         ast_el_add_history [5]
-----------------------------------------------
                0.00    0.00       1/1           main [924]
[46]     0.0    0.00    0.00       1         set_priority [46]
-----------------------------------------------
                0.00    0.00       1/1           main [924]
[47]     0.0    0.00    0.00       1         tdd_init [47]
-----------------------------------------------
                0.00    0.00       1/1           main [924]
[48]     0.0    0.00    0.00       1         term_end [48]
-----------------------------------------------
                0.00    0.00       1/1           main [924]
[49]     0.0    0.00    0.00       1         term_init [49]
-----------------------------------------------
                0.00    0.00       2/2           ast_load [20]
[1258]   0.0    0.00    0.00       2         __ast_load [1258]
                0.00    0.00       8/8           cfg_process [10]
-----------------------------------------------

 This table describes the call tree of the program, and was sorted by
 the total amount of time spent in each function and its children.

 Each entry in this table consists of several lines.  The line with the
 index number at the left hand margin lists the current function.
 The lines above it list the functions that called this function,
 and the lines below it list the functions this one called.
 This line lists:
     index      A unique number given to each element of the table.
                Index numbers are sorted numerically.
                The index number is printed next to every function name so
                it is easier to look up where the function in the table.

     % time     This is the percentage of the `total' time that was spent
                in this function and its children.  Note that due to
                different viewpoints, functions excluded by options, etc,
                these numbers will NOT add up to 100%.

     self       This is the total amount of time spent in this function.

     children   This is the total amount of time propagated into this
                function by its children.

     called     This is the number of times the function was called.
                If the function called itself recursively, the number
                only includes non-recursive calls, and is followed by
                a `+' and the number of recursive calls.

     name       The name of the current function.  The index number is
                printed after it.  If the function is a member of a
                cycle, the cycle number is printed between the
                function's name and the index number.


 For the function's parents, the fields have the following meanings:

     self       This is the amount of time that was propagated directly
                from the function into this parent.

     children   This is the amount of time that was propagated from
                the function's children into this parent.

     called     This is the number of times this parent called the
                function `/' the total number of times the function
                was called.  Recursive calls to the function are not
                included in the number after the `/'.

     name       This is the name of the parent.  The parent's index
                number is printed after it.  If the parent is a
                member of a cycle, the cycle number is printed between
                the name and the index number.

 If the parents of the function cannot be determined, the word
 `<spontaneous>' is printed in the `name' field, and all the other
 fields are blank.

 For the function's children, the fields have the following meanings:

     self       This is the amount of time that was propagated directly
                from the child into the function.

     children   This is the amount of time that was propagated from the
                child's children to the function.

     called     This is the number of times the function called
                this child `/' the total number of times the child
                was called.  Recursive calls by the child are not
                listed in the number after the `/'.

     name       This is the name of the child.  The child's index
                number is printed after it.  If the child is a
                member of a cycle, the cycle number is printed
                between the name and the index number.

 If there are any cycles (circles) in the call graph, there is an
 entry for the cycle-as-a-whole.  This entry shows who called the
 cycle (as parents) and the members of the cycle (as children.)
 The `+' recursive calls entry shows the number of function calls that
 were internal to the cycle, and the calls entry for each member shows,
 for that member, how many times it was called from other members of
 the cycle.



Index by function name

 [1258] __ast_load (config.c) [32] ast_run_atexits (asterisk.c) [9] fix_header (asterisk.c)
   [4] alaw2linear (alaw.c)    [6] ast_strlen_zero (utils.h) [40] get_config_registrations
  [24] ast_active_channels    [14] ast_strlen_zero (utils.h) [13] join2 (cli.c)
  [25] ast_alaw_init          [33] ast_tryconnect (asterisk.c) [1] linear2alaw (alaw.c)
   [3] ast_all_zeros (asterisk.c) [34] ast_ulaw_init       [2] linear2ulaw (ulaw.c)
  [17] ast_cli_register       [35] ast_utils_init         [41] manager_event
  [26] ast_destroy            [21] ast_variable_browse    [42] quit_handler (asterisk.c)
   [5] ast_el_add_history (asterisk.c) [12] ast_verbose   [43] read_ast_cust_config
  [27] ast_el_initialize (asterisk.c) [36] base64_init (utils.c) [44] register_config_cli
   [8] ast_el_read_char (asterisk.c) [37] callerid_init   [45] remoteconsolehandler (asterisk.c)
  [19] ast_el_read_history (asterisk.c) [10] cfg_process (config.c) [46] set_priority (asterisk.c)
  [28] ast_el_write_history (asterisk.c) [38] clear_cust_keywords (config.c) [7] strip (config.c)
  [20] ast_load               [15] cli_prompt (asterisk.c) [47] tdd_init
  [11] ast_log                [39] close_logger           [48] term_end
  [29] ast_readconfig (asterisk.c) [16] console_verboser (asterisk.c) [49] term_init
  [30] ast_register_verbose   [22] fdprint (asterisk.c)   [23] term_quit
  [31] ast_remotecontrol (asterisk.c) [18] find_cli (cli.c)
[root at asterisk1 sbin]# 

Regards.
          AM


More information about the asterisk-dev mailing list