Skip to content
Tcl Source Code History Of Ticket 2905784
Login

History Of Ticket 2905784

Artifacts Associated With Ticket 2905784

  1. Ticket change [7234f22561] (rid 100816) by ferrieux on 2009-11-30 00:16:17:

    1. assignee initialized to: "kennykb"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized 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.
      
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "7 High"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "ferrieux"
    10. subsystem initialized to: "03. Timer Events"
    11. title initialized to: "Sync [after] works too hard"
    12. type initialized to: "Bug"
  2. Add attachment "afteropt.patch" [c8550f5800] (rid 122081) by ferrieux on 2009-11-30 07:18:21.

  3. Ticket change [c8a781ea5a] (rid 122141) by ferrieux on 2009-11-30 07:18:21:

    1. icomment:
      
      
      File Added - 353060: afteropt.patch
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  4. Ticket change [7da6013980] (rid 97272) by ferrieux on 2009-11-30 07:19:53:

    1. icomment:
      The attached patch includes the 2904418  fix, which removes the bulk of the unneeded gettimeofday()s.
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  5. Ticket change [9d71e444f2] (rid 96308) by ferrieux on 2009-12-03 05:33:05:

    1. resolution changed to: "Fixed"
  6. Ticket change [48fcaa873d] (rid 99990) by ferrieux on 2010-10-29 23:31:58:

    1. icomment:
      
      
      File Added - 391655: afteropt2.patch
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  7. Add attachment "afteropt2.patch" [93aa58169f] (rid 105856) by ferrieux on 2010-10-29 23:31:58.

  8. Ticket change [6a87981339] (rid 128169) by ferrieux on 2010-10-29 23:36:39:

    1. icomment:
      Attaching the final patch. Care is taken to never undershoot, using a ceiling() approach when rounding usecs do msecs in time differences. Now a loop of {after 1} consumes < 0.1% CPU instead of 50%. Also, the total syscall budget is much reduced: one select() and three gettimeofday() only for a small [after].
      
      Cost in accuracy:
      
      % time {after 1} 1000
      1060.089 microseconds per iteration
      % time {after 2} 1000
      2061.111 microseconds per iteration
      % time {after 3} 1000
      3062.367 microseconds per iteration
      % time {after 100} 10
      100235.0 microseconds per iteration
      % time {after 10000} 1
      10002067 microseconds per iteration
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  9. Ticket change [06c1e60e4c] (rid 89268) by ferrieux on 2010-10-29 23:42:26:

    1. closedate changed to: "2010-10-29T16:42:26"
    2. closer changed to: "ferrieux"
    3. icomment:
      Committed to HEAD.
      
      
    4. login: "ferrieux"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "ferrieux"