.
D 2026-05-26T17:54:55.742
J assignee nobody
J closer nobody
J cmimetype text/x-markdown
J comment When\sa\sfileevent\sis\sset\sup\sto\sinclude\sthe\sdata\sread\sfrom\sthe\schannel,\sthe\sperformance\sis\sdramatically\sreduced\sdue\sto\sshimmering\sfrom\slist\sto\sstring\sin\sTcl_FileEventObjCmd().\r\n\r\nScript:\r\nset\sup\sa\spipeline,\sand\son\seach\sread\sin\sthe\sfileevent,\sreset\sthe\sfileevent\sscript\sto\sinclude\sthe\snew\sdata.\s\sI\shave\sintentionally\slimited\sthe\sread\sto\s65536\sbytes\sat\sone\stime\sin\sorder\sto\sshow\sthe\sproblem.\r\n\r\n<pre>\r\nproc\sread_channel\s{fd\sdata}\s{\r\n\s\s\s\sappend\sdata\s[read\s$fd\s65536]\r\n\s\s\s\s#\sputs\sstderr\s"[string\slength\s$data]"\r\n\s\s\s\sif\s{[eof\s$fd]}\s{\r\n\tset\snow\s[clock\smilliseconds]\r\n\tputs\sstderr\s"read\s[string\slength\s$data]\sbytes\sin\s[expr\s{$now-$::start}]ms"\r\n\tcatch\s{close\s$fd}\r\n\tset\s::forever\s1\r\n\treturn\r\n\s\s\s\s}\r\n\s\s\s\sfileevent\s$fd\sreadable\s[list\sread_channel\s$fd\s$data]\r\n}\r\nset\sfd\s[open\s"|dd\sif=/dev/zero\sbs=65536\scount=200"\srb]\r\nfconfigure\s$fd\s-blocking\s0\r\nset\sstart\s[clock\smilliseconds]\r\nfileevent\s$fd\sreadable\s[list\sread_channel\s$fd\s""]\r\nvwait\sforever\r\n</pre>\r\n\r\n\r\nTcl_FileEventObjCmd()\sis\schecking\swhether\sto\sremove\sthe\sfileevent\sby\sissuing\sa\sTclGetString()\son\sthe\sfileevent\sscript\sand\schecking\swhether\sthe\sreturned\sstring\sis\s'\\\\0'\r\n\r\n<pre>\r\ngeneric/tclIO.c\s#9285\r\n\s\s\s\s/*\r\n\s\s\s\s\s*\sIf\swe\sare\ssupposed\sto\sdelete\sa\sstored\sscript,\sdo\sso.\r\n\s\s\s\s\s*/\r\n\s\s\s\sif\s(*(TclGetString(objv[3]))\s==\s'\\0')\s{\r\n\tDeleteScriptRecord(interp,\schanPtr,\smask);\r\n\treturn\sTCL_OK;\r\n\s\s\s\s}\r\n</pre>\r\n\r\nThis\scauses\sthe\sfileevent\sscript\sto\sshimmer\sinto\sa\sstring\seach\stime\sthe\sfilevent\sis\sreset.\r\n\r\nProposed\spatch:\sI\sthink\sit\sis\ssafe\sto\sassume\sthat\sfileevent\sscripts\sshould\sbe\svalid\slists,\sso\swe\scould\scheck\sthe\slist\slength\sinstead.\s\sIf\sI\sdo\sso,\sthe\sperfomance\sis\sgreatly\senhanced\s(20x).\r\n\r\nOriginal\stcl9.0.3\r\n<code>\r\nread\s13107200\sbytes\sin\s10245ms\r\n</code>\r\n\r\nWith\sproposed\spatch\sapplied:\r\n<code>\r\nread\s13107200\sbytes\sin\s529ms\r\n</code>
J foundin 9.0.3
J is_private 0
J login ralfixx
J priority 5\sMedium
J private_contact 1d3c95db24e116878d6afed7cf890a89a0effe62
J resolution None
J severity Important
J status Open
J submitter ralfixx
J subsystem 24.\sChannel\sCommands
J title fileevent\spoor\sperformance\sdue\sto\sshimmering
J type RFE
K 7da6c2d04c219e8ed4896b9d4e9eb88e586447f2
U ralfixx
Z 7d88a5e0b0569662c2e78a34e94e4f8e