#372 Speedup for [uplevel] and [upvar]

closed-accepted
5
2004-10-01
2004-09-29
No

This patch speeds up [uplevel] and [upvar] by caching
the result of parsing the string form of the level
indicator in the Tcl_Obj argument instead of always
working with the string form for everything.

Discussion

  • Don Porter

    Don Porter - 2004-09-29

    Logged In: YES
    user_id=80530

    corrected patch applies and compiles.

     
  • Don Porter

    Don Porter - 2004-09-29

    Logged In: YES
    user_id=80530

    The comments in Tcl*GetFrame
    say "modify the interpreter", but
    neither routine actually does that.

     
  • Don Porter

    Don Porter - 2004-09-30

    Logged In: YES
    user_id=80530

    updated patch takes care of comments
    and allows `make genstubs` to succeed.

     
  • Don Porter

    Don Porter - 2004-09-30
     
  • Don Porter

    Don Porter - 2004-09-30

    Logged In: YES
    user_id=80530

    something about the patch
    breaks tcltest:

    dict.test
    Test file error: can't rename "::tcltest::Replace::Puts":
    command doesn't exist
    while executing
    "rename [namespace current]::Replace::Puts ::puts"
    (procedure "::tcltest::Eval" line 16)
    invoked from within
    "::tcltest::Eval {::tcltest::RunTest dict-18.2 {# Test that
    the dictionary is a valid list
    set d [dict create "abc def" 0 "a\{b" 1 "c\}d" 2]
    ..."
    ("uplevel" body line 1)
    invoked from within
    "uplevel 1 [list [namespace origin Eval] $command 1]"
    (procedure "test" line 126)
    invoked from within
    "test dict-18.2 {dict-list relationship} {
    -body {
    # Test that the dictionary is a valid list
    set d [dict create "abc def" 0 "a\{b"..."
    (file "/local/src/tcl/tests/dict.test" line 726)

     
  • Don Porter

    Don Porter - 2004-09-30

    Logged In: YES
    user_id=80530

    Root of the problem appears to
    be line 1965 of tcltest.tcl where
    the literal "1" appears twice.
    First as the "level" argument
    to [uplevel] and second as an
    argument in the command to
    be evaluated up a level. Something
    isn't shimmering right, I'd suspect.

    As a check, if I remove the second "1"
    from that line (and accept the default
    value of that argument, which is 1),
    then the problem goes away.

     
  • Don Porter

    Don Porter - 2004-09-30

    Logged In: YES
    user_id=80530

    This patch should be checked
    against tclbench. I suspect that
    whatever is being saved by
    repeated use of $level by
    multiple [uplevel]s and [upvar]s
    is more than being lost by
    the greatly increased shimmering of
    the literal constant "1" in so many
    logical expressions.

    `make test` sure feels a lot slower anyway.

     
  • Donal K. Fellows

    Logged In: YES
    user_id=79902

    Thanks for the review; I'll have to write a new version that
    is aware of numeric types and avoids the conversion in those
    situations. I suspected I needed to do this anyway ;^)

     
  • Donal K. Fellows

    Logged In: YES
    user_id=79902

    Here's a version that shouldn't have problems with
    shimmering all over the place. Causes no new test failures.
    No idea (formally) what happens in tclbench, but looks good
    in informal trials. ;^)

     
  • Don Porter

    Don Porter - 2004-09-30

    Logged In: YES
    user_id=80530

    revised patch tests ok.

     
  • Donal K. Fellows

    • assigned_to: msofer --> dkf
    • status: open --> closed-accepted
     
  • Donal K. Fellows

    Logged In: YES
    user_id=79902

    Applied to HEAD

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks