> >> Hm.  It doesn't seem that DeadLockCheck is taking very much of the time.
> 
> > Isn't the real time big ?
> 
> Yes, it sure is, but remember that the guy getting useful work done
> (DeadLockCheck) is having to share the CPU with 999 other processes
> that are waking up on every clock tick for just long enough to fail
> to get the spinlock.  I think it's those useless process wakeups that
> are causing the problem.
> 
> If you estimate that a process dispatch cycle is ~ 10 microseconds,
> then waking 999 useless processes every 10 msec is just about enough
> to consume 100% of the CPU doing nothing useful... so what should be
> a few-millisecond check takes a long time, which makes things worse
> because the 999 wannabees are spinning for that much more time.

If so, what about increase the dead lock timer proportional to the
length of the waiting holder queue?

Here are the patches against current to increase the dealock timer by
queue_length secconds.

*** proc.c.orig Thu Jul  5 16:12:32 2001
--- proc.c      Thu Jul  5 16:20:22 2001
***************
*** 506,511 ****
--- 506,512 ----
        int                     myHeldLocks = MyProc->heldLocks;
        PROC       *proc;
        int                     i;
+       int     msec;
  
  #ifndef __BEOS__
        struct itimerval timeval,
***************
*** 625,638 ****
         * Need to zero out struct to set the interval and the microseconds
         * fields to 0.
         */
  #ifndef __BEOS__
        MemSet(&timeval, 0, sizeof(struct itimerval));
!       timeval.it_value.tv_sec = DeadlockTimeout / 1000;
!       timeval.it_value.tv_usec = (DeadlockTimeout % 1000) * 1000;
        if (setitimer(ITIMER_REAL, &timeval, &dummy))
                elog(FATAL, "ProcSleep: Unable to set timer for process wakeup");
  #else
!       time_interval = DeadlockTimeout * 1000000;      /* usecs */
        if (set_alarm(time_interval, B_ONE_SHOT_RELATIVE_ALARM) < 0)
                elog(FATAL, "ProcSleep: Unable to set timer for process wakeup");
  #endif
--- 626,642 ----
         * Need to zero out struct to set the interval and the microseconds
         * fields to 0.
         */
+ 
+       msec = DeadlockTimeout + waitQueue->size * 1000;
+ 
  #ifndef __BEOS__
        MemSet(&timeval, 0, sizeof(struct itimerval));
!       timeval.it_value.tv_sec = msec / 1000;
!       timeval.it_value.tv_usec = (msec % 1000) * 1000;
        if (setitimer(ITIMER_REAL, &timeval, &dummy))
                elog(FATAL, "ProcSleep: Unable to set timer for process wakeup");
  #else
!       time_interval = msec * 1000000; /* usecs */
        if (set_alarm(time_interval, B_ONE_SHOT_RELATIVE_ALARM) < 0)
                elog(FATAL, "ProcSleep: Unable to set timer for process wakeup");
  #endif

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to