.
D 2007-04-16T00:30:38
J assignee dgp
J cmimetype text/plain
J comment Since\swe\sstarted\susing\sTclStackAlloc,\ssome\sof\sthe\sbasic\sassumptions\sunderlying\stebc's\smem\sdesign\sceased\sbeing\scorrect.\sIn\sparticular,\swhen\sthe\sstack\sis\sgrown\sthe\sold\sstack\swill\snow\stypically\sremain\sactive\suntil\severy\sbytecode\srunning\sin\sit\sreturns\s-\sas\sthe\scorresponding\sCallFrames\slive\sthere,\sthe\sold\sstacks\sremain\sactive.\s\n\nThis\smeans\sthat\sthe\srecopying\sof\sstack\sitems\sis\snot\sreally\snecessary.\sThis\spatch\sredesigns\sthe\sExecEnv\ssystem\sto\swork\sdifferently:\sthere\smay\sbe\smany\nstacks\s(in\sa\sdoubly-linked\slist).\sWhen\sthere\sis\snot\senough\sroom\sleft\sin\sthe\sactive\sstack,\sthe\snext\sone\sis\sused\sif\sit\sexists\s(it\swill\sbe\sboth\sthe\slast\sone\sand\sempty)\s-\sbut\sno\selements\sare\stypically\scopied\sover\s(exception:\sgrowth\sfor\s{*}-expansion).\s\n\nOn\sfreeing\sof\sa\sstack\srequirement,\sempty\sstacks\sthat\sare\snot\slast\sare\sckfree'd.\sIn\sthis\smanner\sthe\slargest\sstack\sallocated\sremains\salways\shere,\ssmaller\sstacks\sare\sckfreed\swhen\sthey\scease\sbeing\sused.\sThis\sbehaviour\sis\nsimilar\sto\swhat\sde\sfacto\swe\shave\snow,\swith\sthe\sold\scopies\sbeing\sblocked\sby\sTclStackAlloc'ed\sframes.\n\nWith\sthis\spatch\sboth\sperformance\sand\smemory\susage\sshould\simprove\sin\sgeneral,\salthough\sit\sis\spossible\sto\sdevise\scases\swhere\sit\sconsumes\smore\smemory\sthan\sthe\scurrent\sscheme.\n\nPerformance\simprovements\s(small,\sseem\sto\sbe\sabout\s5%\son\smy\svery\sunreliable\sbenchmariking\ssetup)\sdue\sto:\n\n(a)\sCACHE_STACK_INFO\snow\snecessary,\sa\srunning\sbc\scan\snot\sget\sits\sstack\schanged\s(except\sby\sit\susing\s{*},\sso\sthe\sadaptation\sis\slocalised\sthere)\n\n(b)\swhen\sa\snew\sstack\sis\sneeded\sfor\sa\snew\sbytecode,\sno\sdata\sis\scopied\sover.\sWhen\s{*}\srequires\sa\snew\sstack,\sonly\sthe\sdata\scorresponding\sto\sthe\scurrent\sbc\sis\scopied\sover.\sThe\scurrent\sscheme\srequires\sa\scopy\sof\sthe\scomplete\sstack\scontents,\sincluding\severy\sTclStackAlloc'ed\ssections.\n\n(c)\s(epsilon\ssquared)\sthere\sis\sno\smore\srefcounting\sof\sthe\sstacks\n\nMemory\simprovements:\swhen\sa\snew\sstack\sis\sallocated,\sthe\scomplete\smemory\sis\savailable\sas\snothing\sis\scopied\sover\sfrom\solder\sstacks.\sThe\s*2\sgrowth\smight\sbe\stoo\sgenerous\sunder\sthese\scircumstances,\smaybe\s1.5\swould\sbe\senough?\n\nThe\spatch\salso\screates\sa\snew\sTclStackRealloc,\sthat\spermits\sresizing\sof\sthe\slast\sTclStackAlloc'ed\smemory\s(unused,\sjust\svery\seasy\sto\sadd\sas\sit\suses\sfunctionality\sneeded\sfor\s{*}).\n
J foundin TIP\sImplementation
J is_private 0
J priority 5\sMedium
J resolution None
J status Open
J submitter msofer
J subsystem 41.\sMemory\sAllocation
J title Tcl\sstack\sreform
J type Patch
K 1701202fffffffffffffffffffffffffffffffff
U msofer
Z 25072ab15f419980f8a2b357ec99ca93