Artifacts Associated With Ticket 1452969
Ticket change [d9ad278d34] (rid 107645) by bstellar on 2006-03-18 04:51:54:
- assignee initialized to: "dkf"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Hi I am having considerable performance issue, from v8.0 to v8.3 on regexp for the following statement in my program. I have atttached the program, which responses in same time for 8.0 version as below: Before if - The time is Fri Mar 17 9:17:12 PM US Mountain Standard Time 2006 Inside the if The time is Fri Mar 17 9:17:12 PM US Mountain Standard Time 2006 lsWzrdEcnRequestedByCompleteList_choices and 20 seconds for 8.3: Before if - The time is Fri Mar 17 9:18:53 PM US Mountain Standard Time 2006 Inside the if The time is Fri Mar 17 9:19:22 PM US Mountain Standard Time 2006 lsWzrdEcnRequestedByCompleteList_choices Please help me, if it is known issue. Thanks, Balaji
- foundin initialized to: "final: 8.3.5"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "bstellar"
- subsystem initialized to: "18. Commands M-Z"
- title initialized to: "regexp 20sec delay from 8.0 to 8.3"
- type initialized to: "Bug"
Add attachment "jdReproduceIssue.tcl" [79f47d3ed1] (rid 90220) by bstellar on 2006-03-18 11:51:54.
Ticket change [0b470586b9] (rid 113955) by bstellar on 2006-03-18 11:51:55:
- icomment:
File Added - 171362: jdReproduceIssue.tcl
- login: "bstellar"
- mimetype: "text/plain"
- username: "bstellar"
- icomment:
Ticket change [5eea19ceae] (rid 115718) by bstellar on 2006-03-18 11:53:09:
- priority changed to: "7 High"
Ticket change [f522dc92a2] (rid 130057) by bstellar on 2006-03-18 11:55:15:
- icomment:
Logged In: YES user_id=1479322 This regexp creates delay, please help; if { [ regexp {^(.*)=(.*)$} $sEnvPair sDummy sEnvName sEnvValue ] == 1 } { - login: "bstellar"
- mimetype: "text/plain"
- username: "bstellar"
- icomment:
Ticket change [7a7abcc976] (rid 90326) by bstellar on 2006-03-18 12:04:13:
- priority changed to: "9 Immediate"
Ticket change [02b23e0e8c] (rid 119688) by mistachkin on 2006-03-18 13:13:51:
- subsystem changed to: "43. Regexp"
Ticket change [df36715a00] (rid 114978) by msofer on 2006-03-18 20:35:13:
- foundin changed to: "obsolete: 8.4.13"
- icomment:
Logged In: YES user_id=148712 The performance confirmed bad on modern Tcl (8.3 is already quite old, if you are migrating you should use 8.4). Since 8.0 the regexp engine has been completely replaced; the new unicode awareness does make it slower. However, for your particular case, the use of regexp is probably not necessary: a combination of [string last] and [string range] is much more efficient. Look: % time { if {[set n [string first = $sEnvPair]] != -1} { set sEnvName [string range $sEnvPair 0 [expr {$n-1}]] set sEnvValue [string range $sEnvPair [incr n] end] } } 1000 168.87 microseconds per iteration % time { if {[regexp {^(.*)=(.*)$} $sEnvPair sDummy sEnvName sEnvValue] == 1} { } } 22609833 microseconds per iteration BTW: priority 9 is for release-blocking bugs; this is nowhere near qualifying. - login: "msofer"
- mimetype: "text/plain"
- priority changed to: "5 Medium"
- title changed to: "performance: regexp 20sec delay from 8.0 to 8.3"
- username: "msofer"
Ticket change [32b72cbcb7] (rid 93663) by msofer on 2006-03-18 20:50:30:
- icomment:
Logged In: YES user_id=148712 Oops: [string last], not [string first]. Still much faster: % time { if {[set n [string last = $sEnvPair]] != -1} { set sEnvName [string range $sEnvPair 0 [expr {$n-1}]] set sEnvValue [string range $sEnvPair [incr n] end] } } 1000 1040.019 microseconds per iteration Just by looking at your snippet of code, I'm guessing that you want [string first], and that your regexp is wrong as it will produce the wrong results if anybody has an '=' in his name. - login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [bb711a769e] (rid 129481) by bstellar on 2006-03-19 02:33:20:
- icomment:
Logged In: YES user_id=1479322 Excellent, this help me very much...
- login: "bstellar"
- mimetype: "text/plain"
- username: "bstellar"
- icomment:
Ticket change [1187f5ebd6] (rid 95161) by bstellar on 2006-03-19 02:38:17:
- closedate changed to: "2006-03-18T19:38:17"
- closer changed to: "bstellar"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [a325727ebb] (rid 110006) by msofer on 2006-03-19 02:51:35:
- icomment:
Logged In: YES user_id=148712 bstellar's problem is solved, but the performance bug is still there ...
- login: "msofer"
- mimetype: "text/plain"
- resolution changed to: "None"
- status changed to: "Open"
- username: "msofer"
- icomment:
Ticket change [df42f6034d] (rid 114986) by hobbs on 2006-03-20 03:14:37:
- icomment:
Logged In: YES user_id=72656 The capturing appears to be the real killer. Remove that the slowdown is small. The match is still accurate, so I don't know what extra bits the RE is doing when capturing.
- login: "hobbs"
- mimetype: "text/plain"
- username: "hobbs"
- icomment:
Ticket change [74f623a3a5] (rid 105307) by dkf on 2006-03-20 06:04:31:
- assignee changed to: "hobbs"
- icomment:
Logged In: YES user_id=79902 The RE engine is pretty close to a black box to me; I know how to fix a very small subset of the problems it has, and this is definitely not one of them! Possible consideration: special-case in the outer [regexp] code to detect and handle the case where we have: ^(.*)<SOME_LITERAL>(.*)$ as that's replacable by a simple substring search instead of the much more complex backtracking stuff that the RE engine does. But I've no time to implement this anyway.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
Ticket change [e3fde77244] (rid 87885) by nobody on 2006-03-20 16:21:38:
- icomment:
Logged In: NO Another solution is just to use the ? non greedy quamtifier: regexp {^(.*?)=(.*)$} ... Nice and quick. Also probably what the user intended (in the case where there is a second '='). - login: "nobody"
- mimetype: "text/plain"
- username: "nobody"
- icomment:
Ticket change [ebc47366be] (rid 103587) by hobbs on 2007-12-04 09:08:11:
- icomment:
Logged In: YES user_id=72656 Originator: NO I just found that this actually was introduced in the 8.3 timeframe, and wasn't an issue in 8.2: 000 VERSIONS: 1:8.5b3 2:8.4.17 3:8.3.5 4:8.2.3 5:8.0.5 025 RE extract ini file 76083.10 75661.17 75340.00 152.00 312.00 026 RE extract ini file ng 275.60 301.23 277.00 159.00 -=-
- login: "hobbs"
- mimetype: "text/plain"
- username: "hobbs"
- icomment:
Ticket change [a911088c3b] (rid 99093) by hobbs on 2007-12-04 09:17:38:
- icomment:
Logged In: YES user_id=72656 Originator: NO Oops, never mind the last - it is the RE only, I was actually basing it on the existence of regexp -all, which wasn't intro'd until 8.3, but the RE is bad for 8.2 as well.
- login: "hobbs"
- mimetype: "text/plain"
- username: "hobbs"
- icomment: