Scheduling client task processing time

The time slice configuration parameter prevents executing tasks from monopolizing engines during execution. The scheduler allows a task to execute on an Adaptive Server engine for a maximum amount of time equal to the time slice and cpu grace time values combined, using default times for time slice (100 milliseconds, 1/10 of a second, or equivalent to one clock tick) and cpu grace time (500 clock ticks, or 50 seconds).

Adaptive Server scheduler does not force tasks off an Adaptive Server engine. Tasks voluntarily relinquish the engine at a yield point, when the task does not hold a vital resource such as a spinlock.

Each time the task comes to a yield point, it checks to see if time slice has been exceeded. If it has not, the task continues to execute. If execution time does exceed time slice, the task voluntarily relinquishes the engine. However, if the task does not yield even after exceeding time slice, Adaptive Server terminates the task after it exceeds cpu grace time. The most common cause for a task not yielding is a system call that does not return in a timely manner.

For more information about using sp_sysmon to determine how many times tasks yield voluntarily, see “Scheduling tasks to the engine”.

To increase the amount of time that CPU-intensive applications run on an engine before yielding, assign execution attributes to specific logins, applications, or stored procedures.

If the task has to relinquish the engine before fulfilling the client request, the task goes to the end of the run queue, unless there are no other tasks in the run queue. If no tasks are in the queue when an executing task reaches a yield point during grace time, Adaptive Server grants the task another processing interval.

Normally, tasks relinquish the engine at yield points prior to completion of the cpu grace time interval. It is possible for a task not to encounter a yield point and to exceed the time slice interval. If time slice is set too low, an engine may spend too much time switching between tasks, which tends to increase response time. If time slice is set too high, CPU-intensive processes may monopolize the CPU, which can increase response time for short tasks. If your applications encounter timeslice errors, adjusting the value for time slice has no affect, but adjusting the value for cpu grace time does. However, research the cause of the time slice error before adjusting the value for cpu grace time. You may need to contact Sybase Technical Support.

When the cpu grace time ends, Adaptive Server terminates the task with a time slice error. If you receive a time slice error, try increasing the time up to four times the current time for cpu grace time. If the problem persists, call Sybase Technical Support.

See Chapter 4, “Distributing Engine Resources.”