|
2007-12-04
| ||
| 09:17 | • Ticket [1452969fff] performance: regexp 20sec delay from 8.0 to 8.3 status s... artifact: a911088c3b user: hobbs | |
| 09:08 | • Ticket [1452969fff]: 4 changes artifact: ebc47366be user: hobbs | |
|
2006-03-20
| ||
| 16:21 | • Ticket [1452969fff]: 4 changes artifact: e3fde77244 user: nobody | |
| 06:04 | • Ticket [1452969fff]: 5 changes artifact: 74f623a3a5 user: dkf | |
| 03:14 | • Ticket [1452969fff]: 4 changes artifact: df42f6034d user: hobbs | |
|
2006-03-19
| ||
| 02:51 | • Open ticket [1452969fff]. artifact: a325727ebb user: msofer | |
| 02:38 | • Closed ticket [1452969fff]. artifact: 1187f5ebd6 user: bstellar | |
| 02:33 | • Ticket [1452969fff]: 4 changes artifact: bb711a769e user: bstellar | |
|
2006-03-18
| ||
| 20:50 | • Ticket [1452969fff]: 4 changes artifact: 32b72cbcb7 user: msofer | |
| 20:35 | • Ticket [1452969fff]: 7 changes artifact: df36715a00 user: msofer | |
| 13:13 | • Ticket [1452969fff]: 1 change artifact: 02b23e0e8c user: mistachkin | |
| 12:04 | • Ticket [1452969fff]: 1 change artifact: 7a7abcc976 user: bstellar | |
| 11:55 | • Ticket [1452969fff]: 4 changes artifact: f522dc92a2 user: bstellar | |
| 11:53 | • Ticket [1452969fff]: 1 change artifact: 5eea19ceae user: bstellar | |
| 11:51 | • Ticket [1452969fff]: 4 changes artifact: 0b470586b9 user: bstellar | |
| 11:51 | • Add attachment jdReproduceIssue.tcl to ticket [1452969fffffffff|1452969... artifact: 79f47d3ed1 user: bstellar | |
| 04:51 | • New ticket [1452969fff] regexp 20sec delay from 8.0 to 8.3. artifact: d9ad278d34 user: bstellar | |
performance: regexp 20sec delay from 8.0 to 8.3
Open1452969fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 19 years ago
Descriptionplain2006-03-18 04:51:54
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
bstellarplain2006-03-18 11:51:55
File Added - 171362: jdReproduceIssue.tcl
bstellar Ticket [1452969fff]: 1 change
[History diff]2006-03-18 11:53:09
bstellarplain2006-03-18 11:55:15
Logged In: YES
user_id=1479322
This regexp creates delay, please help;
if { [ regexp {^(.*)=(.*)$} $sEnvPair sDummy
sEnvName sEnvValue ] == 1 } {
bstellar Ticket [1452969fff]: 1 change
[History diff]2006-03-18 12:04:13
mistachkin Ticket [1452969fff]: 1 change
[History diff]2006-03-18 13:13:51
msoferplain2006-03-18 20:35:13
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.
msoferplain2006-03-18 20:50:30
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.
bstellarplain2006-03-19 02:33:20
Logged In: YES user_id=1479322 Excellent, this help me very much...
bstellar Closed ticket [1452969fff].
[History diff]2006-03-19 02:38:17
msoferplain2006-03-19 02:51:35
Logged In: YES user_id=148712 bstellar's problem is solved, but the performance bug is still there ...
hobbsplain2006-03-20 03:14:37
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.
dkfplain2006-03-20 06:04:31
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.
nobodyplain2006-03-20 16:21:38
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 '=').
hobbsplain2007-12-04 09:08:11
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 -=-
hobbsplain2007-12-04 09:17:38
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.
Log in (anonymous is fine) to add a comment.
Attachments:
- jdReproduceIssue.tcl [download] added by bstellar on 2006-03-18 11:51:54. [details]