Skip to content
Tcl Source Code Artifact [83bdbc9a76]
Login

Artifact [83bdbc9a76]

Artifact 83bdbc9a76415f5421bfb1352353aee80ffde467:

Ticket change [83bdbc9a76] - New ticket [2942697fffffffff|2942697fff] <i>Pathologically slow regexp execution</i>. by tgl on 2010-01-30 06:46:24.
D 2010-01-30T06:46:24
J assignee pvgoran
J cmimetype text/plain
J comment The\sattached\stest\scase\s"slowregexp.tcl"\sdemonstrates\sa\scase\sthat\sresults\sin\sO(N^2)\sslowdown\sin\sexecution\sof\sa\sregexp\smatch,\sas\sa\sresult\sof\snested\ssearches\sin\screvdissect:\sthe\souter\sinvocation\ssearches\sfor\sa\ssuitable\smidpoint,\sand\sfor\seach\spossible\smidpoint\sthe\sinner\sexecution\schecks\sall\spossible\slocations\sfor\sits\smidpoint.\nI\stested\sthis\sagainst\s8.5.7\sbut\sit\sdoesn't\slook\slike\sthe\srelevant\sfiles\shave\schanged\ssince\sthen.\n\nThere\sare\sa\snumber\sof\sways\sthat\sthis\smight\sbe\sattacked,\sbut\sI\sattach\sa\sfairly\ssimple\spatch\sthat\sseems\sto\simprove\smatters\sfor\sme.\s\sThe\sidea\sis\sthat\sto\sverify\sa\smidpoint\srequires\sa\slongest()\scall\sas\swell\sas\srecursively\scdissect()ing\sthe\sleft\sand\sright\ssides\s---\sbut\swe\scould\sdo\sthe\slongest()\scheck\sfirst\ssince\sthat's\sthe\sfastest.\s\sThis\sreduces\sthe\sruntime\sof\sthe\sgiven\stest\scase\sabout\s500X\son\smy\smachine.\s\sThere\sare\stwo\spossible\sflaws\sin\sthis\ssolution:\n\n1.\sIt\swon't\swork\sif\slongest()\sdepends\son\scdissect()\shaving\sset\sup\ssome\sstate\s---\sfor\sinstance,\sestablishing\sbackref\sstring\sboundaries.\s\sAs\sfar\sas\sI\scan\ssee,\sthat\sisn't\sthe\scase,\sbut\sI'm\sno\sexpert\son\sthis\scode\sso\sI\smight've\smissed\ssomething.\s\sI\scan\ssay\sthat\sthe\sTcl\sregression\stests\sstill\spass,\sthough.\n\n2.\sIt's\sconceivable\sthat\sthere\sare\scases\swhere\sthis\sway\sis\sslower\srather\sthan\sfaster.\s\sI\scan't\sanswer\sthat\sat\sall.\s\sThe\sregression\stest\scases\sseem\sto\stake\sjust\sabout\sthe\ssame\samount\sof\stime\sas\sbefore,\sthough.\n\nFYI,\sthis\sproblem\swas\soriginally\ssubmitted\sto\sthe\sPostgres\sproject\sat\shttp://archives.postgresql.org/pgsql-hackers/2010-01/msg02864.php
J foundin obsolete:\s8.5.7
J is_private 0
J priority 5\sMedium
J resolution None
J status Open
J submitter tgl
J subsystem 43.\sRegexp
J title Pathologically\sslow\sregexp\sexecution
J type Bug
K 2942697fffffffffffffffffffffffffffffffff
U tgl
Z 936ef947fe61eaf0222abf6498c1a521