Skip to content
Tcl Source Code Artifact [07b2786dc6]
Login

Artifact [07b2786dc6]

Artifact 07b2786dc6490bf7f2ef7aeae7e49a280fc6bcccf18bd32f9ea87b318605f5d3:

Ticket change [07b2786dc6] - Ticket [893f8cc5db3ba8bd|893f8cc5db] <i>Nested mutexes following TIP 509</i> status still Open with 3 other changes by sebres on 2025-09-17 12:18:10.
D 2025-09-17T12:18:10.395
J icomment <blockquote>>\sIn\sthe\smean\stime,\sI\ssaw\ssebres'\sbranch\s(sebres--non-reentrant-mutex)...</blockquote>\r\n\r\nAlthough\smy\sown\spreference\sis\sto\suse\snon-reentrant\smutexes\sfurther\s(neither\ssee\sthe\snecessity\sfor\sTIP#509,\snor\sI\sthink\sit\sis\sgood\sidea\sat\sall),\sbut\sthis\sbranch\swas\smade\sfor\sSchelte,\sto\stest\shis\sstrange\sissue\swith\s9.0,\swhere\sin\sopposite\sto\s8.6,\sthe\sCPU\sload\s(and\seval\stimes)\sgrows\swith\sthe\stime\sand\snew\sfindings\sare\s-\stracing\swith\sbpftrace\sshows\sthat\smutexes\smay\sbe\sresponsible\sfor\sthat.\r\n\r\nHere\sis\sa\squote\sfrom\stcl-chat:\r\n\r\n<i\sstyle="display:block;\spadding-left:10pt;">&lt;schelte&gt;\sI\sfinally\smanaged\sto\sget\ssome\sdata\sthat\smay\sbe\suseful\sregarding\sthe\scpu\susage\sincreasing\son\sTcl\s9:\sAfter\sthe\sapplication\shas\sbeen\srunning\sfor\s3\sweeks,\scalls\sto\sTcl_MutexLock()\stake\s70%\slonger\sthan\sjust\safter\sthe\sapplication\sis\sstarted.\r\n\r\n&lt;schelte&gt;\sTcl_GetIndexFromObjStruct()\sincreased\sby\s20%.\sBut\sTcl_MutexLock()\sshows\sthe\sbiggest\sdifference.\r\n</i>\r\n\r\nMy\sassumption\s-\ssince\sthe\sunix\smutexes\suse\scommon\salloc,\sand\schange\sthe\smemory\s(lock\scounter,\slocked\sthread)\sin\sthe\sblock\sthat\smay\sbe\sshared\sacross\sthreads\s(potentially\swith\sother\smemory,\sif\sit\sis\snot\saligned\sto\sCPU\scache\sgranularity),\sso\swe\sprobably\send\sup\swith\ssomething\slike\s[3d1c409f1a]\safter\spotential\sdefragmentation.\r\n\r\nTo\stest\sthis,\sI\sprovided\sa\ssmall\spatch\sfor\shis\s9.0,\sreverting\sreentrant\smutexes,\sbut\sit'd\snot\swork\sanymore\safter\sapn's\sencoding\sfix\s[0433b67adc5fb0b9],\swhat\sexpects\sreentrant\smutexes\snow\sand\swould\scause\sa\sdeadlock\sby\ssetting\sof\ssystem\sencoding.\sTherefore,\sthe\sbranch\sin\scase\sSchelte\swould\sneed\sit\sfor\snewer\sversions\sas\swell.\r\n\r\nThat's\sit.\r\n\r\nP.S.\sBasic\ssystem\sfunctions\ssuch\sas\smutexes\sare\snot\sfor\snaive\sattempts\sat\simprovement\sand\sdefinitely\srequire\sdeeper\sknowledge\sof\sthe\ssubject\smatter.\r\nUnfortunately\sI\sdidn't\ssee\sthe\sTIP\sat\sthat\stime\spoint,\sotherwise\sI\shad\sdefinitely\sexpress\smy\sdoubts\sabout\sit.<br/>\r\nRegarding\sthe\sreentrant\smutexes\s-\ssomeone,\swho\smay\sneed\sit,\sdoesn't\sunderstand\sthe\sprimary\sessential\sprerequisite\sof\slocking\smechanisms\s-\sthe\slock\sshall\sbe\sas\sshort\sas\spossible.\sFrom\sthis\spoint\sof\sview\s-\srecursive\susage\sof\sthem\sis\stotally\sabsurd.\sMoreover\sit'd\squasi\sencourage\sthe\sdevs\sto\swrite\s"bad"\scode.
J login sebres
J mimetype text/x-fossil-wiki
K 893f8cc5db3ba8bd6bed80ce89a0a75c6088a37c
U sebres
Z 320a55b4528b0208380226988aab5258