Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 507691899875264a7e616c4cd420606faf47f98c
Ticket: 3485833fffffffffffffffffffffffffffffffff
trace - inexplicable large overhead by ensemble commands
User & Date: sebres on 2012-02-08 18:43:04
Changes

  1. assignee changed to: "dgp"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Hello, 
    
    I've found that by "execution" trace some ensemble commands produce a lot of overhead... 
    without trace it is comparable with not ensemble commands
    i have own profiler (to check which code works slowly), that calls somthing like this :
    
    Tcl_CreateObjTrace( interp, level, TCL_ALLOW_INLINE_COMPILATION | ((TCL_TRACE_ANY_EXEC) >> 2),
             &tclexProfilerTraceProc, inDbgObj, NULL );
    The C procedure "tclexProfilerTraceProc" i have rewritten to test this, that it performs "return TCL_OK;" only.
    
    Strange is the execution times of "string length" and "::tcl::string::length" are not different, 
    but "string range" or "string first" are 100 times slower as its not ensemble commands "::tcl::string::range" or "::tcl::string::first".
    
    That overhead make me not possible, to profile anything code, using ensembles.
    
    Tcl code to be "profiled":
    %%%%
    set s [string repeat A 50000]; puts ok
    puts "--- string range ----"
    puts [time {::tcl::string::range $s 2000 2001} 100000]
    puts [time {::string range $s 2000 2001} 10000]
    puts "--- string first ----"
    puts [time {::tcl::string::first A $s 2000} 100000]
    puts [time {::string first A $s 2000} 10000]
    puts "--- string length ---"
    puts [time {::tcl::string::length $s} 100000]
    puts [time {::string length $s} 10000]
    puts "--- test ------------"
    proc ::test1_string_range {s from to} {set a 5}
    proc ::test2_string_range {ens s from to} {set a 5}
    puts [time {::test1_string_range $s 2000 2001} 10000]
    puts [time {::test2_string_range range $s 2000 2001} 10000]
    %%%%
    
    Result is :
    ok
    --- string range ----
    1.4 microseconds per iteration
    168.8 microseconds per iteration !!!
    --- string first ----
    1.09 microseconds per iteration
    168.8 microseconds per iteration !!!
    --- string length ---
    0.31 microseconds per iteration
    0.0 microseconds per iteration
    --- test ------------
    1.6 microseconds per iteration
    1.5 microseconds per iteration
    
    
  4. foundin changed to: "obsolete: 8.5.11"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "sebres"
  10. subsystem changed to: "46. Traces"
  11. title changed to:
    trace - inexplicable large overhead by ensemble commands
    
  12. type changed to: "Bug"