Skip to content
Tcl Source Code History Of Ticket 2873596
Login

History Of Ticket 2873596

Artifacts Associated With Ticket 2873596

  1. Ticket change [44d8ad26db] (rid 116772) by apnadkarni on 2009-10-06 17:39:20:

    1. assignee initialized to: "hobbs"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      I want to process data received over the network in a safe interpreter 
      (although for the purposes of this question, the safe-ness is 
      irrelevant). Roughly speaking, I invoke the safe interpreter as
      
        safeinterp eval [list process_request $received_data]
      
      What I've found is that invoking the slave interpreter in this manner is 
      slower than processing in the same interpreter by two orders of 
      magnitude or more. Here is a tkcon session simulating the issue:
      
      (woof) 51 % interp create ip
      ip
      (woof) 52 % ip eval {proc slaveproc arg {}}
      (woof) 53 % string length [set s [string repeat x 100000]]
      100000
      (woof) 54 % time {ip eval [list slaveproc $s]} 10
      3335.4 microseconds per iteration
      
      So roughly, 3.3ms to pass 100K into an empty proc in the slave. By 
      comparison, passing it to a proc in the same interp (using eval for 
      consistency)
      
      (woof) 55 % proc masterproc arg {}
      (woof) 56 % time {eval [list masterproc $s]} 10
      9.3 microseconds per iteration
      
      So use of a slave interpreter in this fashion is MUCH slower.
      
      Timestamping the C code, the slowdown with the slave interp seems to 
      happen because of shimmering in SlaveEval (the internal rep for the list 
      is thrown away and converted to a string and then converted back in the 
      slave).
      
      Workaround - Alexander Ferrieux on tcl-core pointed out a workaround. To quote him -
      ----
      While I admit I don't fully understand this necessity, it turns out
      the multiple-argument code path doesn't have the limitation, since it
      directly calls  Tcl_ConcatObj on its list of arguments, and it is well
      known that TCO is optimized for all-pure-list arguments (dating back
      to Paul Duffin's work on Concat objects IIRC). Hence one can derive a
      script-level idiom guaranteeing a shimmerless path:
      
            ip eval [list slaveproc] [list $s]
      -----
      
      I also tested with 8.5.2. It is equally slow, and what's more Alexander's workaround does not work there (it's still slow), presumably because Tcl_ConcatObj is not optimized in 8.5.2 (conjecture)
      
      
      /Ashok
      
    4. foundin initialized to: "obsolete: 8.6b1.1"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "apnadkarni"
    10. subsystem initialized to: "20. [interp]"
    11. title initialized to: "Slowness in passing data through interp eval"
    12. type initialized to: "Bug"
  2. Ticket change [2a5d62e295] (rid 118554) by dgp on 2009-10-07 00:48:25:

    1. icomment:
      
      do you have any tests without the
      corruption imposed by [string length] ?
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  3. Ticket change [b60a4ebe7c] (rid 125356) by dgp on 2009-10-07 00:51:36:

    1. icomment:
      
      this is fixed on the HEAD (for 8.6b2):
      
      % interp create ip
      ip
      % ip eval {proc slaveproc arg {}}
      % string length [set s [string repeat x 100000]]
      100000
      % time {ip eval [list slaveproc $s]} 10
      13.7 microseconds per iteration
      % proc masterproc arg {}
      % time {eval [list masterproc $s]} 10
      11.1 microseconds per iteration
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  4. Ticket change [4be467f838] (rid 126780) by dgp on 2009-10-07 00:56:49:

    1. icomment:
      
      bug is also not present in the 8.5.7 release:
      
      % interp create ip
      ip
      % ip eval {proc slaveproc arg {}}
      % string length [set s [string repeat x 100000]]
      100000
      % time {ip eval [list slaveproc $s]} 10
      12.2 microseconds per iteration
      % proc masterproc arg {}
      % time {eval [list masterproc $s]} 10
      9.6 microseconds per iteration
      
      
      leaving open just for sake of 8.4.20.
      
      
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  5. Ticket change [1402b3390e] (rid 124319) by dgp on 2009-10-07 00:56:50:

    1. priority changed to: "3 Low"
  6. Ticket change [ba23534458] (rid 129268) by dgp on 2009-10-08 03:54:47:

    1. assignee changed to: "dgp"
  7. Ticket change [6e2bd65927] (rid 140213) by dgp on 2014-10-09 16:16:07:

    1. closedate changed to: "2456940.17786013"
    2. closer changed to: "dgp"
    3. comment changed to:
      I want to process data received over the network in a safe interpreter 
      (although for the purposes of this question, the safe-ness is 
      irrelevant). Roughly speaking, I invoke the safe interpreter as
      
        safeinterp eval [list process_request $received_data]
      
      What I've found is that invoking the slave interpreter in this manner is 
      slower than processing in the same interpreter by two orders of 
      magnitude or more. Here is a tkcon session simulating the issue:
      
      (woof) 51 % interp create ip
      ip
      (woof) 52 % ip eval {proc slaveproc arg {}}
      (woof) 53 % string length [set s [string repeat x 100000]]
      100000
      (woof) 54 % time {ip eval [list slaveproc $s]} 10
      3335.4 microseconds per iteration
      
      So roughly, 3.3ms to pass 100K into an empty proc in the slave. By 
      comparison, passing it to a proc in the same interp (using eval for 
      consistency)
      
      (woof) 55 % proc masterproc arg {}
      (woof) 56 % time {eval [list masterproc $s]} 10
      9.3 microseconds per iteration
      
      So use of a slave interpreter in this fashion is MUCH slower.
      
      Timestamping the C code, the slowdown with the slave interp seems to 
      happen because of shimmering in SlaveEval (the internal rep for the list 
      is thrown away and converted to a string and then converted back in the 
      slave).
      
      Workaround - Alexander Ferrieux on tcl-core pointed out a workaround. To quote him -
      ----
      While I admit I don't fully understand this necessity, it turns out
      the multiple-argument code path doesn't have the limitation, since it
      directly calls  Tcl_ConcatObj on its list of arguments, and it is well
      known that TCO is optimized for all-pure-list arguments (dating back
      to Paul Duffin's work on Concat objects IIRC). Hence one can derive a
      script-level idiom guaranteeing a shimmerless path:
      
            ip eval [list slaveproc] [list $s]
      -----
      
      I also tested with 8.5.2. It is equally slow, and what's more Alexander's workaround does not work there (it's still slow), presumably because Tcl_ConcatObj is not optimized in 8.5.2 (conjecture)
      
      
      /Ashok
      
    4. login: "dgp"
    5. mimetype: "text/plain"
    6. resolution changed to: "Out of Date"
    7. severity changed to: "Minor"
    8. status changed to: "Closed"