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 - 2004, 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.972 2010/04/06 15:20:52 marty Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.973 2010/05/06 10:58:56 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:619: Inside #if defined(THREADS) and #if defined(SLOW_REQ_BT)
  static void dump_slow_req (Thread.Thread thread)   {    string desc = sprintf ("%O", thread);    if (sscanf (desc, "Thread.Thread(%d)", int i)) desc = (string) i;    report_debug ("### Thread %s has been busy for more than %d seconds.\n",    desc, SLOW_REQ_BT);    describe_all_threads();   }   #endif    + // 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; +    local static 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:661: Inside #if defined(THREADS)
   busy_threads++;    thread_flagged_as_busy = 1;   #ifdef SLOW_REQ_BT    if (h[0] != bg_process_queue)    // Don't want this on the background jobs (at least not    // with the same timeout).    slow_req_call_out =    slow_req_monitor->call_out (dump_slow_req, SLOW_REQ_BT,    this_thread());   #endif +  handler_num_runs++; +  int st = gethrtime();    h[0](@h[1]); -  +  int dt = gethrtime() - st;    h=0;    busy_threads--;    thread_flagged_as_busy = 0; -  +  if (dt > 10000) handler_num_runs_001s++; +  if (dt > 50000) handler_num_runs_005s++; +  if (dt > 150000) handler_num_runs_015s++; +  if (dt > 500000) handler_num_runs_05s++; +  if (dt > 1000000) handler_num_runs_1s++; +  if (dt > 5000000) handler_num_runs_5s++; +  if (dt > 15000000) handler_num_runs_15s++; +  handler_acc_time += dt;   #ifdef SLOW_REQ_BT    slow_req_monitor->remove_call_out (slow_req_call_out);   #endif    } 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
Roxen.git/server/base_server/roxen.pike:992: 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.   static constant bg_time_buffer_max = 30;   static constant bg_time_buffer_min = 0;   static 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(); + } +    static 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);       if (mixed err = catch {
Roxen.git/server/base_server/roxen.pike:1029: Inside #if defined(THREADS) and #if defined(DEBUG_BACKGROUND_RUN)
   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]),    master()->describe_program (task[0])) :    sprintf ("%O", task[0]),    map (task[1], lambda (mixed arg)    {return sprintf ("%O", arg);}) * ", ",    bg_queue->size()); -  float task_time = gauge { +    #endif -  +  bg_num_runs++; +  int st = gethrtime(); +  float task_time = 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.    task[0] (@task[1]); - #ifdef DEBUG_BACKGROUND_RUN +     }; -  +  int dt = gethrtime() - st; +  if (dt > 10000) bg_num_runs_001s++; +  if (dt > 50000) bg_num_runs_005s++; +  if (dt > 150000) bg_num_runs_015s++; +  if (dt > 500000) bg_num_runs_05s++; +  if (dt > 1000000) bg_num_runs_1s++; +  if (dt > 5000000) bg_num_runs_5s++; +  if (dt > 15000000) bg_num_runs_15s++; +  bg_acc_cpu_time += (int)(1E6*task_time); +  bg_acc_time += dt; + #ifdef DEBUG_BACKGROUND_RUN    report_debug ("background_run done, took %f sec\n", task_time);   #endif       if (busy_threads > 1) bg_last_busy = time();    }    }) {    bg_process_running = 0;    handle (bg_process_queue);    throw (err);    }