Roxen.git / server / base_server / roxen.pike

version» Context lines:

Roxen.git/server/base_server/roxen.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2009, Roxen IS.   //   // The Roxen WebServer main program.   //   // Per Hedbor, Henrik Grubbström, Pontus Hagland, David Hedbor and others.   // ABS and suicide systems contributed freely by Francesco Chemolli    - constant cvs_version="$Id: roxen.pike,v 1.1063 2010/05/03 12:18:49 marty Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.1064 2010/05/06 12:20:40 noring Exp $";      //! @appears roxen   //!   //! The Roxen WebServer main program.      // The argument cache. Used by the image cache.   ArgCache argcache;      // Some headerfiles   #define IN_ROXEN
Roxen.git/server/base_server/roxen.pike:794: Inside #if defined(THREADS)
  local protected Queue handle_queue = Queue();   //! Queue of things to handle.   //! An entry consists of an array(function fp, array args)      local protected int thread_reap_cnt;   //! Number of handler threads in the process of being stopped.      protected int threads_on_hold;   //! Number of handler threads on hold.    + // Global variables for statistics + int handler_num_runs = 0; + int handler_num_runs_001s = 0; + int handler_num_runs_005s = 0; + int handler_num_runs_015s = 0; + int handler_num_runs_05s = 0; + int handler_num_runs_1s = 0; + int handler_num_runs_5s = 0; + int handler_num_runs_15s = 0; + int handler_acc_time = 0; + int handler_acc_cpu_time = 0; +    local protected void handler_thread(int id)   //! The actual handling function. This functions read function and   //! parameters from the queue, calls it, then reads another one. There   //! is a lot of error handling to ensure that nothing serious happens if   //! the handler function throws an error.   {    THREAD_WERR("Handle thread ["+id+"] started");    mixed h, q;    set_u_and_gid (1);   #ifdef TEST_EUID_CHANGE
Roxen.git/server/base_server/roxen.pike:830: Inside #if defined(THREADS)
   do {   // if (!busy_threads) werror ("GC: %d\n", gc());    cache_clear_deltas();    THREAD_WERR("Handle thread ["+id+"] waiting for next event");    if(arrayp(h=handle_queue->read()) && h[0]) {    THREAD_WERR(sprintf("Handle thread [%O] calling %O(%{%O, %})",    id, h[0], h[1] / 1));    set_locale();    busy_threads++;    thread_flagged_as_busy = 1; +  handler_num_runs++;    -  +  int start_hrtime = gethrtime(); +  float handler_vtime = gauge {   #ifndef NO_SLOW_REQ_BT    if (h[0] != bg_process_queue &&    // Leave out bg_process_queue. It makes a timeout on    // every individual job instead.    (monitor = slow_req_monitor) && slow_req_timeout > 0.0) {    call_out = monitor->call_out (dump_slow_req, slow_req_timeout,    this_thread(), slow_req_timeout);    h[0](@h[1]);    monitor->remove_call_out (call_out);    }    else   #endif -  +  {    h[0](@h[1]); -  +  } +  }; +  float handler_rtime = (gethrtime() - start_hrtime)/1E6;       h=0;    busy_threads--;    thread_flagged_as_busy = 0; -  +  if (handler_rtime > 0.01) handler_num_runs_001s++; +  if (handler_rtime > 0.05) handler_num_runs_005s++; +  if (handler_rtime > 0.15) handler_num_runs_015s++; +  if (handler_rtime > 0.50) handler_num_runs_05s++; +  if (handler_rtime > 1.00) handler_num_runs_1s++; +  if (handler_rtime > 5.00) handler_num_runs_5s++; +  if (handler_rtime > 15.00) handler_num_runs_15s++; +  handler_acc_cpu_time += (int)(1E6*handler_vtime); +  handler_acc_time += (int)(1E6*handler_rtime);    } else if(!h) {    // Roxen is shutting down.    report_debug("Handle thread ["+id+"] stopped.\n");    thread_reap_cnt--;   #ifdef NSERIOUS    if(!thread_reap_cnt) report_debug("+++ATH\n");   #endif    return;    }   #ifdef DEBUG
Roxen.git/server/base_server/roxen.pike:1172: Inside #if defined(THREADS)
     // Use a time buffer to strike a balance if the server is busy and   // always have at least one busy thread: The maximum waiting time in   // that case is somewhere between bg_time_buffer_min and   // bg_time_buffer_max. If there are only short periods of time between   // the queue runs, the max waiting time will shrink towards the   // minimum.   protected constant bg_time_buffer_max = 30;   protected constant bg_time_buffer_min = 0;   protected int bg_last_busy = 0; + int bg_num_runs = 0; + int bg_num_runs_001s = 0; + int bg_num_runs_005s = 0; + int bg_num_runs_015s = 0; + int bg_num_runs_05s = 0; + int bg_num_runs_1s = 0; + int bg_num_runs_5s = 0; + int bg_num_runs_15s = 0; + int bg_acc_time = 0; + int bg_acc_cpu_time = 0;    -  + int bg_queue_length() + { +  return bg_queue->size(); + } +    protected void bg_process_queue()   {    if (bg_process_running) return;    // Relying on the interpreter lock here.    bg_process_running = 1;       int maxbeats =    min (time() - bg_last_busy, bg_time_buffer_max) * (int) (1 / 0.04);      #ifndef NO_SLOW_REQ_BT
Roxen.git/server/base_server/roxen.pike:1217: Inside #if defined(THREADS) and #if defined(DEBUG_BACKGROUND_RUN)
   programp (task[0]) ?    sprintf ("%s: %s", Program.defined (task[0]),    master()->describe_program (task[0])) :    sprintf ("%O", task[0]),    map (task[1], lambda (mixed arg)    {return sprintf ("%O", arg);}) * ", ",    bg_queue->size());   #endif       float task_vtime, task_rtime; +  bg_num_runs++;      #ifndef NO_SLOW_REQ_BT    if ((monitor = slow_req_monitor) && slow_req_timeout > 0.0) {    call_out = monitor->call_out (dump_slow_req, slow_req_timeout,    this_thread(), slow_req_timeout);    int start_hrtime = gethrtime (1);    task_vtime = gauge {    if (task[0]) // Ignore things that have become destructed.    // Note: BackgroundProcess.repeat assumes that there are    // exactly two refs to task[0] during the call below.
Roxen.git/server/base_server/roxen.pike:1243: Inside #if defined(THREADS)
  #endif    {    int start_hrtime = gethrtime (1);    task_vtime = gauge {    if (task[0])    task[0] (@task[1]);    };    task_rtime = (gethrtime (1) - start_hrtime) / 1e9;    }    +  if (task_rtime > 0.01) bg_num_runs_001s++; +  if (task_rtime > 0.05) bg_num_runs_005s++; +  if (task_rtime > 0.15) bg_num_runs_015s++; +  if (task_rtime > 0.50) bg_num_runs_05s++; +  if (task_rtime > 1.00) bg_num_runs_1s++; +  if (task_rtime > 5.00) bg_num_runs_5s++; +  if (task_rtime > 15.00) bg_num_runs_15s++; +  bg_acc_cpu_time += (int)(1E6*task_vtime); +  bg_acc_time += (int)(1E6*task_rtime); +     if (task_rtime > 60.0)    report_warning ("Warning: Background job took more than one minute "    "(%g s real time and %g s cpu time):\n"    " %s (%s)\n%s",    task_rtime, task_vtime,    functionp (task[0]) ?    sprintf ("%s: %s", Function.defined (task[0]),    master()->describe_function (task[0])) :    programp (task[0]) ?    sprintf ("%s: %s", Program.defined (task[0]),