Overview
| Artifact ID: | 7234f22561a704752df24ecafc02b5df43f97210 |
|---|---|
| Ticket: | 2905784fffffffffffffffffffffffffffffffff
Sync [after] works too hard |
| User & Date: | ferrieux on 2009-11-30 00:16:17 |
Changes
- assignee changed to: "kennykb"
- cmimetype changed to: "text/plain"
- comment changed to:
Synchronous [after] makes many calls to the underlying OS's getttimeofday() or equivalent. This is due to an ill-defined responsibility boundary between AfterDelay() and Tcl_Sleep(). Indeed, Tcl_Sleep() already has the logic to repeatedly check the current time and wait, not trusting the OS's time, and also taking car of virtual time. However, AfterDelay repeats this logic one level up, calling Tcl_Sleep in a loop until endTime is reached. The existence of the loop in itself has good reasons, namely respecting a reasonable granularity for limits or Async stuff. But in the degenerate, but important, case of "small" delays below those limits, a very simple optimization (patch attached) lets AfterDelay call Tcl_Sleep exactly once, essentially "trusting" it on the accuracy of the resulting wait. Additionally, one trivial move of the Tcl_GetTime in the loop removes one unwanted extra gettimeofday(). The bottom line: this patch makes a small [after] generate only 3 gettimeofday()s: one on entry, to compute the endTime, and two inside Tcl_Sleep. Squeezing one more out would need a change in the Tcl_Sleep() API; I'm not attempting that.
- foundin changed to: "None"
- is_private changed to: "0"
- priority changed to: "7 High"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "ferrieux"
- subsystem changed to: "03. Timer Events"
- title changed to: "Sync [after] works too hard"
- type changed to: "Bug"