Overview
| Artifact ID: | 1e3fd1839e3db55eb48cbc84788fc7133132cd0e |
|---|---|
| Ticket: | 3485833fffffffffffffffffffffffffffffffff
trace - inexplicable large overhead by ensemble commands |
| User & Date: | sebres on 2017-01-04 14:25:01 |
Changes
- closer changed to: "nobody"
- 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 - icomment:
Interim status of subject: Even without any tracing, current trunk have still very large overhead, that concerns to ensemble handling (by the way, greater than in 8.5). It could be better explained using my new command "timerate" (fairly more precise by measurement as the "time"), currently available for trunk-based branches in https://github.com/sebres/tcl/pull/3 Following example will provide you insight about ensemble-overhead (compiled as well as non-compiled execution takes by ensemble 70% more time): ``` % set s [string repeat A 50000]; puts ok ok % # calibrate to minimize influence of measurement overhead (and byte code execution overhead): % timerate -calibrate {} 0.04537374883248807 µs/#-overhead, 0.045506 µs/#, 42895062 #, 21974929 #/sec % # test compiled execution: % timerate {string first A $s 2000} 0.321560 µs/#, 2725287 #, 3109837 #/sec % timerate {::tcl::string::first A $s 2000} 0.191541 µs/#, 4220926 #, 5220810 #/sec % # calibrate again (slower, non-compiled direct execution via TclEvalObjEx): % timerate -direct -calibrate {} 0.07950384713110215 µs/#-overhead, 0.080109 µs/#, 24366669 #, 12482924 #/sec % timerate -direct {string first A $s 2000} 0.313794 µs/#, 2542604 #, 3186803 #/sec % timerate -direct {::tcl::string::first A $s 2000} 0.190985 µs/#, 3697004 #, 5236000 #/sec ``` - login: "sebres"
- mimetype: "text/plain"
- severity changed to: "Minor"