status still Open with 3 other changes
by
apnadkarni
2024-04-02 07:35:31.
D 2024-04-02T07:35:31.285
J icomment Nathan,\r\n\r\nI'll\smake\sone\slast\sattempt\sat\spersuasion\sthat\r\n\r\n-\sfrom\san\sarchitectural\spoint\sof\sview,\sgenerating\sI/O\scallback\sevents\swithout\r\nknowing\schannel\sstate\sis\snot\sat\sall\san\sappropriate\smodel\sfor\sasync\sevent\sdriven\r\nI/O.\r\n\r\n-\sThe\srelated\schanges\sin\strunk\svis-a-vis\s8.6\sare\sbroken\sin\smultiple\saspects,\r\nmostly\sbecause\sof\sthe\sabove.\r\n\r\nThe\smotivation\sfor\sasync\si/o\sis\sthat\sapplications\scan\sdo\suseful\swork\swhile\r\nwaiting\sfor\sI/O\sto\scomplete.\sNow\sthis\sby\sitself\sdoes\snot\sneed\sselect\son\sUnix,\r\ncompletion\sports\son\sWindows\sor\sfileevent\sin\sTcl.\sOne\scan\sjust\scall\sthe\si/o\r\nfunctions\sand\scheck\sfor\s"EAGAIN"\sequivalents.\sThere\sare\smultiple\sproblems\swith\r\nthis\sas\sthe\sapplication\shas\sto\spoll:\r\n\r\n-\sTry\stoo\sfrequently\sand\sits\swasting\sprocessing\scycles\sprocessing\sEAGAINS.\r\n\r\n-\sTry\stoo\sinfrequently\sand\sthere\sis\san\sunnecessary\sdelay\s/\slatency\sin\sservicing\r\nI/O\srequests.\r\n\r\nAn\sevent\ssystem\ssolves\sboth\sthe\sabove\s**as\slong\sas\sevents\sare\sgenerated\sbased\son\r\nthe\sI/O\sstate.**\sNo\stime\sis\swasted\sin\sunnecessary\spolls\sand\sthere\sis\snot\r\nadditional\sdelay\sonce\sthe\schannel\sis\sready\sfor\sI/O.\sHowever,\sif\sI/O\sevents\sare\r\ngenerated\sbased\son\stimers\s**with\sno\sknowledge\sof\sI/O\sstate**\sit\shas\sexactly\sthe\r\nsame\seffect\sas\sapplication\spolling!\sIt\sis\scompletely\spointless\s-\sgenerating\r\nevents\swhen\sI/O\sstate\sdoes\snot\sreflect\schannel\sreadiness,\sand\sunnecessary\sdelays\r\nafter\sreadiness\sbefore\sthe\stimer\sexpires.\sIf\syou\struly\sbelieve\sthis\sas\sa\r\nsolution,\syou\sshould\sbe\samenable\sto\scompletely\sgetting\srid\sof\sTcl's\sI/O\srelated\r\nevent\ssubsystem!\sThe\sapplication\scould\sjust\sgenerate\swrite\sevents\susing\s`chan\r\npostevent`\son\sa\sregular\sbasis\swith\s`after`.\sThis\sis\sbasically\swhat\sthe\scurrent\r\nTcl\s9\simplementation\sdoes,\squeueing\sevents\son\sa\stimer\sbasis.\r\n\r\nThe\sabove\sis\sthe\smotivation\sfor\sasync/event-driven\soperation\sfrom\san\r\nefficiency\sand\sperformance\sperspective.\sHowever,\sthere\sis\salso\sthe\s"simple"\r\nmatter\sof\scorrectness.\sAn\sevent\sshould\snot\sbe\sgenerated\sprematurely\r\nreflecting\sa\sstate\sthat\sdoes\snot\sactually\sexist.\r\n\r\nIn\sother\swords,\sfrom\sboth\sthe\sperformance\sand\scorrectness\spoint\sof\sview,\sthe\r\ncurrent\stimer\sbased\swrite\sevent\sgeneration\sin\sChannelTimerProc\s**which\sis\snot\r\nbased\son\schannel\sstate**\sis\sfundamentally\sflawed.\sIt\sdoes\snot\sfulfil\sthe\r\nintended\spurpose\sof\san\sevent\sbased\si/o\ssystem\sby\sessentially\spolling,\sand\r\nmoreover\sdoes\snot\smeet\scorrectness\scriteria\sas\sit\shas\sno\sidea\sof\schannel\sstate\r\nand\sgenerates\sevents\sprematurely\s(14.11\sfailure).\r\n\r\nAll\sthe\sabove\sis\sa\scomment\son\sevent\sdriven\si/o\sand\schannels\sin\sgeneral.\sNow\sas\r\nfar\sas\srefchans\sare\sconcerned,\sthere\sis\sa\slimitation\sin\sthe\srefchan\sframework\sas\r\nmentioned\sin\san\searlier\spost\swhich\sled\sto\sthe\soriginal\sdefect\syou\slogged\sin\sthis\r\nticket.\sTo\sreiterate,\sthere\sis\sno\sscript\slevel\sequivalent\sof\sthe\r\n`Tcl_EventSetupProc`\sand\s`Tcl_EventCheckProc`.\sThus\s*some*,\snot\sall,\srefchans\r\nare\sforced\sto\suse\sa\stimer\sbase\sscheme\sto\sgenerate\sthese\sevents.\sHowever,\s**this\r\nmust\sbe\sdone\sby\sthe\srefchan\sscript\simplementation\sitself\sand\snot\sthe\sgeneric\r\nchannel\sinfrastructure**\sbecause\sthe\sformer\sknows\sthe\schannel\sstate,\sthe\slatter\r\ndoes\snot.\sThis\sis\sstill\snot\sideal\sfrom\sthe\sefficiency\sperspective,\sbut\sbeing\r\nable\sto\scheck\sstate,\sit\sis\sat\sleast\scorrect.\r\n\r\nI\sbelieve\sthat\sis\show\sAndreas'\svirtchannel\smodules\sin\stcllib\swork.\sAnd\sas\sproof\r\nof\sconcept,\sfollowing\sthe\stcllib\smodel,\sI've\smodified\syour\srefchan\r\nimplementation\sof\s44.6\sand\sattached\sas\srefchan-async-redux.tcl\s(proof\sof\sconcept\r\nonly\smodeling\stcllib).\sThis\sworks\sin\sTcl\s8.6\sas\swell\s(which\syour\sversion\sdid\r\nnot).\sTL;DR\sthe\schanges\syou\smade\sto\sthe\score\sin\sChannelTimerProc\s(a)\slead\sto\sat\r\nleast\stwo\sbugs\s11.14\sand\sevent\sq\sstarvation,\s(b)\saffected\schannels\sother\sthan\r\nrefchans,\s(c)\swere\sunnecessary.\r\n\r\nGiven\s(imho)\sthe\senhancement\sof\sthe\srefchan\sframework\sas\stoo\smuch\sof\sa\srisk\sfor\r\na\s9.0\srelease,\sI\ssee\stwo\spossibilities\sthat\sare\sacceptable\s(not\sperfect,\sjust\r\nacceptable)\sfor\s9.0\srelease:\r\n\r\n-\srevert\sthe\simplementation\sto\swhat\s8.6\sdoes.\sNo\sneed\sfor\s-buffering\snone\sin\r\nthis\scase\sbut\sthe\sscript\slevel\srefchan\simplementation\shas\sto\sgenerate\stimer\r\nevents,\s**check\sstate**\sand\sthen\sdo\sa\s`after\sidle\safter\s0\schan\spostevent`\sfrom\r\nthe\stimer\scallback.\sSee\stcllib\sor\sattached\ssample.\sAlternatively,\sthe\srefchan\r\ncan\sdo\sthe\s-buffering\snone\sitself\sand\savoid\sthe\stimer\sif\sthat\ssuits\sits\spurpose.\r\n\r\n-\sIf\syou\sdo\snot\swant\sthe\schannel\sscript\simplementation\sto\shave\sthat\sresponsibility,\r\n(I\swould\slike\sto\sknow\swhy\snot)\sthen\sset\s-buffering\snone\sfor\srefchans\sas\r\nproposed\sin\smy\sbranch.\r\n\r\nI\sprefer\s(1).\r\n\r\nI\sam\spretty\smuch\sgoing\sto\sstay\ssilent\son\sthis\stopic\snow.\sI\scannot\sprovide\sany\r\nmore\sclarity\son\smy\sobjections.\sFinally,\ssome\sgroup\sof\speople\shas\sto\sdecide\r\non\sa\scourse\sof\saction.\sHopefully,\sthat\sgroup\sis\snot\sjust\syou\sand\sme.
J login apnadkarni
J mimetype text/x-markdown
K de232b49f26da1c18e07513d4c7caa203cd27910
U apnadkarni
Z a97e54119cbd2b85b112382f483550e4