Skip to content
Tcl Source Code History Of Ticket 458361ffffffffff
Login

History Of Ticket 458361ffffffffff

Artifacts Associated With Ticket 458361ffffffffff

  1. Ticket change [cc13cd1870] (rid 95631) by msofer on 2001-09-04 12:02:38:

    1. assignee initialized to: "msofer"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      (see also
      http://groups.google.com/groups?hl=en&safe=off&threadm=3B9458E6.93CEF15F%40ActiveState.com&prev=/groups%3Foi%3Ddjq%26as_ugroup%3Dcomp.lang.tcl)
      
      The output of
          proc testproc {args} {set x 1}
          proc test0 {} {puts "proc test0:  [time {testproc}
      100000]"}
          proc test1 {} {puts "proc test1:  [time {testproc }
      100000]"}
          proc test2 {} {eval {puts "proc test2:  [time
      {testproc} 100000]"}}
      
          puts "top level: [time {testproc } 100000]"
          test0
          test1
          test2
      is
          [mig@mini unix]$ tclsh test2
          top level: 4 microseconds per iteration
          proc test0:  20 microseconds per iteration
          proc test1:  4 microseconds per iteration
          proc test2:  4 microseconds per iteration
      
      I think that the problem in test0 is caused by
      shimmering of the literal
      "testproc":
        - it is converted to tclByteCodeType by Tcl_EvalObjEx
        - it is converted to tclCommandNameType by
      Tcl_ExecuteByteCode
      
      So, the difference would be:
         - in test0, "testproc" is parsed, compiled and
      looked up as a 
           command repeatedly
         - at top-level and in test2, "testproc" never
      becomes a 
           tclByteCodeType 
         - in test1, there are two different literals:
      "testproc " is always 
           tclByteCodeType, "testproc" is always
      tclCommandNameType
      
      This would explain why the difference only occurs at
      calls with no
      arguments.
      
      
      
    4. foundin initialized to: "None"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "msofer"
    9. subsystem initialized to: "47. Bytecode Compiler"
    10. title initialized to: "slow calls of cmds with no arguments"
    11. type initialized to: "Bug"
  2. Ticket change [67b200f06f] (rid 102935) by msofer on 2001-09-04 19:06:58:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      [set tcl_traceCompile 2] confirms the repeated compilation
      of "testproc" only in test0.
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  3. Add attachment "singleWord.patch" [ebde18172f] (rid 103604) by msofer on 2001-09-11 04:49:21.

  4. Ticket change [d19615c018] (rid 113377) by msofer on 2001-09-11 04:49:21:

    1. assignee changed to: "hobbs"
    2. icomment:
      
      
      File Added - 10617: singleWord.patch
      
      Logged In: YES 
      user_id=148712
      
      I enclose a patch that avoids this shimmering. I do think
      the patch is safe; it would produce if ever something that
      is *not* a command namecould have shimmered into a
      tclCmdNameType Tcl_Obj ...
      
      This is most unlikely, but it *could* conceivably happen I
      guess ...
      
      
    3. login: "msofer"
    4. mimetype: "text/plain"
    5. username: "msofer"
  5. Ticket change [ab7b2bc0d7] (rid 101128) by hobbs on 2001-09-11 06:14:33:

    1. icomment:
      Logged In: YES 
      user_id=72656
      
      Can you elaborate on how you think something could shimmer 
      into tclCmdNameType without being a command name?
      
      
    2. login: "hobbs"
    3. mimetype: "text/plain"
    4. username: "hobbs"
  6. Ticket change [75ab9a99c5] (rid 105425) by msofer on 2001-09-11 06:42:58:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      Consider
      
        set a 1
        namespace eval tst {
            proc {set a} {args} {return YES}
            proc t {} {{set a}}
            t
        }
      
      After this the literal {set a} is a tclCmdNameType. If you
      now send the script {set a} to Tcl_EvalObjEx from the global
      namespace you may get in trouble.
      
      Now: command names with spaces are risky/difficult in any
      case. Plus, this is an abstract fear: I did not manage to
      trigger such an error from a script.
      
      Also: I have the same fear for a script accidentally
      shimmering into a pure list before being [eval]'ed, causing
      the pure list optimisation to produce an error. As far as I
      know, there are no reports of such a thing ever happening -
      so the fear is probably unfounded.
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  7. Ticket change [cd627afbdf] (rid 95881) by hobbs on 2001-09-11 07:03:07:

    1. icomment:
      Logged In: YES 
      user_id=72656
      
      Given the two-legged crane of Tcl objects, I believe your 
      fear is unfounded.  It is a valid tclCmdNameType or it is 
      not.  I'm not seeing how that can be invalidated.
      
      
    2. login: "hobbs"
    3. mimetype: "text/plain"
    4. username: "hobbs"
  8. Ticket change [ffe0c0d046] (rid 108839) by msofer on 2001-09-11 18:41:54:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      The feared scenario is:
        - a literal (say {set a}) is validly interpreted as a
      command name in one context, hence retains tclCmdNameType
        - later on, the same literal is evaled in another context
      where it is *not* a valid command name but it *is* a valid
      script
      
      Now, without the patch there would be no problem: the
      literal is parsed and compiled. With the patch, there is no
      parsing or compiling: the literal is still assumed to be a
      command name; the lookup fails, you get an "invalid command
      name"
      
      OK, I did find how to how to trigger this:
      
        set a 1
        namespace eval tst {
             proc {set a} {args} {return YES}
             proc t {} {{set a}}
             t
         }
         namespace eval tst2 {set a}
      
      Without the patch, the last return value is "1". With the
      patch, you get
          invalid command name "set a"
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  9. Add attachment "singleWord.patch2" [754f7ed4f4] (rid 105369) by msofer on 2001-09-11 19:06:18.

  10. Ticket change [87d522ba58] (rid 131768) by msofer on 2001-09-11 19:06:18:

    1. icomment:
      
      
      File Added - 10655: singleWord.patch2
      
      Logged In: YES 
      user_id=148712
      
      Enclosing a corrected patch: if there is an error, the long
      execution path is restored.
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  11. Ticket change [b0e2a5a468] (rid 98056) by hobbs on 2001-09-12 02:20:16:

    1. icomment:
      Logged In: YES 
      user_id=72656
      
      Should the decr really only occur in the error case?
      
      
    2. login: "hobbs"
    3. mimetype: "text/plain"
    4. username: "hobbs"
  12. Add attachment "singleWord.patch3" [56851b385d] (rid 94336) by msofer on 2001-09-12 02:38:40.

  13. Ticket change [2507fe8c04] (rid 131212) by msofer on 2001-09-12 02:38:40:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      Remark that there are (with this one) four different
      execution paths in Tcl_EvalObjEx:
      (1) pure list optimisation
      (2) direct parse+eval 
      (3) the new one for single-word commands
      (4) execute bytecodes
      
      Actually, the decr is only in the _no_error_ case; when
      there is an error result, execution falls through to the
      long Nr.4 path, which decr's objPtr at the end (after lable
      _done_).
      
      Side remark: wouldn't it be better if all 4 paths ended at
      the same spot, with the (faster)
         TclDecrRefCount(objPtr);
         return result;
      
      I illustrate this in patch Nr.3
      
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  14. Ticket change [8cc9aa4c2a] (rid 127795) by msofer on 2001-09-12 02:38:41:

    1. icomment:
      
      
      File Added - 10670: singleWord.patch3
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  15. Ticket change [4eea282bff] (rid 125731) by msofer on 2001-10-05 20:37:11:

    1. assignee changed to: "msofer"
    2. icomment:
      Logged In: YES 
      user_id=148712
      
      Retaking ownership of this ticket; it is somewhat related to
      [Bug 467523]; solving that one may result in a better
      solution to this bug too ...
      
      
    3. login: "msofer"
    4. mimetype: "text/plain"
    5. username: "msofer"
  16. Ticket change [7d15660f7d] (rid 97186) by msofer on 2002-01-09 23:43:25:

    1. title changed to: "single word scripts get recompiled at each call"
  17. Ticket change [92a5055e5a] (rid 120800) by msofer on 2002-01-10 05:16:09:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      The approach in these patches is suspect at best; to
      illustrate, what *should* be the return of this script?
        
         proc {set a} {} {return 0}
         set a 1
         {set a}
         catch {set a} res
         set res
      
      The point is: should the {set a} argument to [catch] be
      taken as one or two words, being that both interpretations
      make sense? We (dgp, kennykb, myself) think it should be two
      words - the approach in these patches fails to satisfy this.
      
      Putting the patch on hold - the issue of "command names with
      spaces" requires further thought.
      
      The correct approach may be quite different anyway: avoid
      sharing the literals so promiscuosly.
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  18. Ticket change [c57b6cd6d6] (rid 112008) by dgp on 2003-11-13 08:35:02:

    1. foundin changed to: "obsolete: 8.4a3"
  19. Ticket change [fed77b7688] (rid 108655) by msofer on 2004-07-08 05:17:05:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      Fixed in HEAD by unsharing the cmdName literal for
      single-word scripts.Not backported to core-8-4-branch due to
      [Bug 983660] (leaking unshared literals); fix of 983660 not
      backported until performance implications are clear.
      
      Leaving open until backporting is done or decided against.
      
      Note that the fix is not perfect, shimmering will still
      occur in cases where the single-word script is called as a
      command somewhere else (as opposed to: in its own body). The
      correct solution may be to have a more discriminating policy
      for literals - one table for cmdNames, one for varNames, one
      for nsNames, one for 'everything else' (scripts, strings, ...)?
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. resolution changed to: "Fixed"
    5. username: "msofer"
  20. Ticket change [f27c41bbc0] (rid 109545) by msofer on 2004-07-09 01:50:58:

    1. closedate changed to: "2004-07-08T18:50:58"
    2. closer changed to: "msofer"
    3. icomment:
      Logged In: YES 
      user_id=148712
      
      Decided not to backport: this is just a relatively minor
      performance bug, it doesn't seem reasonable to risk the
      currently stable branch without more testing.
      
      
    4. login: "msofer"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "msofer"