Overview
| Artifact ID: | c3e17d3a15fa04137b004decf0212b0ec2e203b7 |
|---|---|
| Ticket: | 1038541fffffffffffffffffffffffffffffffff
CPU-Performance increase with MM-Timer |
| User & Date: | kennykb on 2004-10-04 21:02:22 |
Changes
- icomment:
Logged In: YES user_id=99768 This problem is not quite a bug. On Windows, as indeed on most systems, when a thread asks to delay for a given time, the time is rounded to a "clock tick" - one cycle of some external oscillator. On the various versions of Windows, the size of a clock tick varies; it may be as long as 60 ms or as short as a millisecond. The [after] command attempts to hide this granularity. When the wait time is shorter than a clock tick, the kernel call that it uses actually makes the thread wait for zero time, and become immediately available for redispatch. At that point, the Tcl notifier checks whether any timer events are ready for service, finds that none is (because the necessary millisecond has not yet elapsed), and again delays for zero time. This zero delay causes a behavior in which the notifier is using apparently all the CPU. If any other thread is contending for the CPU, however, it will get its full time quantum when it comes to the head of the queue. At that point, the notifier thread will use a short burst of CPU checking for events, relinquish the processor, and allow the CPU-intensive thread to proceed once again. As far as I can tell, while it appears alarming, the CPU usage when short [after] events are scheduled is simply CPU time that is transferred from the idle loop. If you've actually observed system performance being adversely affected, rather than simply an alarming number on the Task Manager, please reopen this issue and we'll investigate further. At the present time, as far as we can tell, the fact that Tcl takes over part of the system's idle time has not been observed to have any significant impact.
- login: "kennykb"
- mimetype: "text/plain"
- username: "kennykb"