Skip to content
Tcl Source Code Artifact [e3e88f0be6]
Login

Artifact [e3e88f0be6]

Artifact e3e88f0be665938008784d9ad8bd281a0be926b69afa3475867172c1bffe431d:

Ticket change [e3e88f0be6] - Ticket [da16d155744c55d5|da16d15574] <i>unacceptable long file read time by fix of [db4f2843cd]</i> status still Open with 4 other changes by oehhar on 2024-01-22 13:54:23.
D 2024-01-22T13:54:23.515
J icomment I\smade\ssome\stracing\ssessions\swith\sthe\stwo\sversions:\r\n\r\nOld:\r\n<verbatim>\r\nTcl_AppendToObj(objPtr,\sNULL,\sdstLimit);\r\n</verbatim>\r\n\r\nand\sNew:\r\n\r\n<verbatim>\r\nTcl_SetObjLength(objPtr,\snumBytes\s+\sdstLimit);\r\n</verbatim>\r\n\r\nIMHO,\sthe\sperformance\sdifference\scomes\sfrom\sthe\sdifferent\sallocation\sstrategies\sof\sthe\s4096\sbytes\sread\sby\seach\sread\scommand.\sEach\scommand\sgrows\sthe\sbuffer\sby\s4096\sbytes\s(plus\s2\sbytes\sfor\seventual\sfull\sutf\scode\s(on\s8.6\swith\sTCL_CHAR_MAX=3).\r\n\r\nThe\sold\smethod\suses\sGrowStringBuffer()\swhich\sdoubles\sthe\sbuffer\son\seach\srun.\r\nIn\sconsequence,\sonly\sa\smuch\ssmaller\samount\sof\srealloc-calls\sis\sused,\sbut\seventually\sa\slarge\schunk\sof\smemory\sis\swasted.\r\n\r\nThe\snew\smethod\suses\sckrealloc()\sfor\seach\schunk\sof\s4096\sbytes.\r\n\r\nThe\stest\sstring\ssize\sis\s1000000000.\sSo\s1000000000\s/\s4096\s=\s244141\sreallocs\shappen\swith\sincreasing\ssize.\r\n\r\nThe\sgreat\sfactor-two\slogic\sof\sGrowStringBuffer()\sis\sprobably\snot\sused\sby\sTcl_SetObjLength(),\sas\sthis\sdoes\snot\ssignal\sthe\spotential\sof\sa\sfuture\sgrowth.\r\n\r\nThe\s2nd\scomparison\sof\sthe\stwo\smethods\sis,\sif\sa\sUNICODE\sstring\sis\sprefered.\r\n\r\nThe\scalled\sroutine\sis\s"Tcl_AppendLimitedToObj()".\r\nHere\sis\sthe\spreference\sof\sUnicode\sas\sstated\sby\sSergey:\r\n\r\n<verbatim>\r\n\s\s\s\sif\s(stringPtr->hasUnicode\s&&\sstringPtr->numChars\s>\s0)\s{\r\n\tAppendUtfToUnicodeRep(objPtr,\sbytes,\stoCopy);\r\n\s\s\s\s}\selse\s{\r\n\tAppendUtfToUtfRep(objPtr,\sbytes,\stoCopy);\r\n\s\s\s\s}\r\n</verbatim>\r\n\r\nIn\sthe\stracing\sI\sdid,\sthere\sis\snever\sa\schance\sto\sget\sa\sUNICODE\sstring.\r\n\r\nIn\sconsequence,\sI\swould\ssuggest\sthe\sfollowing:\r\n\r\n\s\s\s-\s\s\sunwind\sthe\spatch\r\n\s\s\s-\s\s\sadd\sa\stest,\sthat\sunicode\sis\snever\sin\sthe\sbuffer\sat\sthis\sposition.\r\n\r\nAs\sin\sboth\scases\s"SetStringFromAny(NULL,\sobjPtr)"\sis\scalled,\san\seventual\sunicode\srepresentation\smay\sbe\sinvalidated\safter\sthis\scall.\sSOmething\slike:\r\n\r\n<verbatim>\r\nSetStringFromAny(NULL,\sobjPtr);\r\nstringPtr\s=\sGET_STRING(objPtr);\r\nstringPtr->hasUnicode\s=\s0;\r\nstringPtr->numChars\s=\s-1;\r\n</verbatim>\r\n\r\nIs\sthis\sa\splan\s?\r\n\r\nThank\syou\sand\stake\scare,\r\nHarald
J login oehhar
J mimetype text/x-fossil-wiki
J username oehhar
K da16d155744c55d5a769a81b57b0e80045e8391a
U oehhar
Z 682dbb978c418a001ec3603e12340aa5