.
D 2026-08-17T21:21:59.964
J comment Every\sexpensive\soperation\squarry\sperforms\sruns\ssynchronously\sin\sthe\srequest\sgoroutine,\swith\sno\sadmission\scontrol\sanywhere\sin\sthe\sprocess.\sThere\sis\sno\ssemaphore,\sno\sworker\spool,\sand\sno\squeue:\sthe\sonly\sbound\son\sconcurrent\swork\sis\show\smany\srequests\sarrive.\n\n##\sWhat\sthat\scosts\stoday\n\nMeasured\son\sthe\seleven-repository\scorpus:\n\n|\soperation\s|\scost\s|\sbound\s|\n|---|---|---|\n|\s`zit\sls\s--long`\s(tk,\s2,198\sfiles)\s|\s2,632\sms\s|\snone\s|\n|\s`zit\scat`\s(small\sfile)\s|\s147\sms\s|\snone\s|\n|\s`zit\sinfo`\s(resolve\sa\sname)\s|\s148\sms\s|\snone\s|\n|\s`archive.get`\s(tarball)\s|\sseconds\s|\s256\sMiB\s**buffered\sin\smemory**\s|\n|\s`attachment.get`\s|\s—\s|\s32\sMiB\sbuffered\s|\n\nBefore\sthe\scontent\scache\slanded,\sthe\sfile\spage\ssaturated\sat\s**32\sreq/s**\sand\sthen\swent\sbackwards\s—\s24\sreq/s\sat\stwenty\sconcurrent\sreaders,\swith\slatency\s4x\sthe\ssingle-request\scost.\sCaching\sraised\sthat\sceiling\sto\s~200\sreq/s\sbut\sdid\snot\sintroduce\sa\sbound;\sit\smoved\swhere\sthe\swall\sis.\n\n**The\surgent\scase:\s`archive.get`\sis\s`ops.Anonymous`\sand\sbuffers\sup\sto\s`maxArchiveBytes`\s(256\sMiB)\sper\srequest\swith\sno\sconcurrency\slimit.**\sTen\sconcurrent\sanonymous\srequests\sis\s2.5\sGiB\sresident\sand\sten\szit\ssubprocesses.\sThis\sis\sa\sdenial\sof\sservice\sreachable\swithout\scredentials\sand\sshould\sbe\sbounded\sahead\sof\sthe\swider\sdesign.\n\n##\sTwo\sproblems,\stwo\smechanisms\n\nThey\sare\sworth\sseparating,\sbecause\sconflating\sthem\sproduces\sa\squeue\sfor\sthings\sa\sreader\sshould\ssimply\swait\sfor.\n\n**1.\sBounded\sconcurrency\sfor\ssynchronous\sreads**\s—\s`ls`,\s`cat`,\s`diff`,\s`info`.\n\nA\sreader\swants\sthe\sfile\snow;\smaking\sit\sa\sjob\sis\sworse\sthan\smaking\sit\swait.\sWhat\sthese\sneed\sis\sa\ssemaphore\ssized\sto\sthe\smachine,\sso\sN\sconcurrent\sreaders\sdo\snot\sfork\sN\ssubprocesses,\splus\s**load\sshedding**:\spast\sa\swait\sthreshold,\srefuse\swith\s503\sand\s`Retry-After`\srather\sthan\saccept\swork\sthat\swill\stime\sout\sanyway.\sAn\saccepted\srequest\sthat\scannot\sbe\sserved\son\stime\sis\sworse\sthan\sa\srefused\sone,\sbecause\sit\sconsumes\sthe\scapacity\sthat\swould\shave\sserved\ssomeone\selse.\n\nQueue\sdepth\sand\swait\stime\sbecome\sthe\sscaling\ssignal.\n\n**2.\sAsync\sjobs\sfor\sgenuinely\slong\swork**\s—\s`archive`,\s`reindex`,\smirror\spull,\sand\seventually\sbulk\soperations.\n\nThese\sreturn\sa\sjob\sid\simmediately.\sThe\sUI\sshows\squeued\s→\srunning\s→\sdone\swith\sa\slink\sto\sthe\sresult.\sThis\sis\swhat\smakes\scost\svisible\sinstead\sof\sfelt.\n\n##\squarry\salready\shas\sthe\smachinery\n\nNone\sof\sthis\sis\snew\sinfrastructure,\swhich\sis\sthe\sargument\sfor\sdoing\sit\sproperly\srather\sthan\sscattering\ssemaphores:\n\n-\s**JetStream\swork-queue**\s—\sthe\swebhook\sdispatcher\salready\suses\sone\sfor\sdurable,\sat-least-once\sdelivery.\n-\s**`ci_run`\sin\sOLTP**\s—\sthe\sprecedent\sfor\stracking\sasync\swork\swith\sa\sstatus\sa\spage\scan\srender\s(`internal/oltp/ci.go`).\sA\s`job`\stable\sis\sthe\ssame\sshape.\n-\s**Datastar\sSSE**\s—\sthe\sfleet\spage\salready\sstreams\slive\sstate,\sand\s0001\sPrinciple\s3's\srule\sis\salready\ssatisfied\sthere:\sit\srenders\sstate\sat\sload\sand\sa\srefresh\sworks\swithout\sJavaScript.\sA\sjob\spage\sfollows\sthe\ssame\spattern.\n-\s**`/fleet`**\s—\sthe\sadmin\ssurface\swhere\squeue\sdepth,\swait\spercentiles\sand\srejection\scounts\sbelong,\sbeside\sthe\singest\shealth\salready\sthere.\n\n##\sThe\sSQLite\ssingle-writer\sargument\n\nThis\sis\sthe\spart\sthat\smakes\sa\squeue\sstructural\srather\sthan\sdefensive.\n\nSQLite\sadmits\sone\swriter\sat\sa\stime.\sToday\sthat\sconstraint\sis\shandled\semergently\s—\s`busy_timeout=5000`\son\sboth\sthe\sindex\sand\sOLTP\s—\sso\scontention\ssurfaces\sas\sa\srequest\sthat\sstalls\sup\sto\sfive\sseconds\sand\sthen\sfails\swith\sSQLITE_BUSY.\sThe\slease\s(`Repo.Guard`,\s0001\s§3)\sserializes\swrites\sACROSS\snodes\sbut\snothing\sserializes\sthem\swithin\sone.\n\nA\swrite\squeue\smakes\sthe\sconstraint\sexplicit:\swrites\sare\sserialized\sby\sdesign,\sthe\sdepth\sis\sobservable,\sand\sa\scaller\slearns\s"queued,\sposition\s3"\sinstead\sof\sstalling\son\sa\slock\sand\stiming\sout.\sIt\salso\sremoves\sthe\spathological\scase\swhere\sseveral\swriters\seach\shold\sa\sfive-second\stimeout\swhile\sa\slong\sfold\sholds\sthe\swrite\slock.\n\n##\sProposed\sshape\n\n1.\s**`internal/work`**\s—\sa\sbounded\sexecutor:\snamed\slanes,\seach\swith\sa\sconcurrency\slimit\sand\sa\squeue\sdepth\scap.\sLanes\sbecause\sa\sslow\sarchive\smust\snot\sstarve\sa\s`cat`;\sone\sglobal\spool\swould\slet\sthe\smost\sexpensive\soperation\smonopolise\sthe\scheapest.\n2.\s**Lanes\sto\sstart\swith**:\s`read`\s(zit\sreads,\ssized\sto\scores),\s`write`\s(depth\s1\s—\sthe\sSQLite\swriter),\s`bulk`\s(archive,\sreindex,\smirror;\sdepth\s1–2).\n3.\s**Shedding**\s—\spast\sthe\sdepth\scap,\srefuse\swith\s`ops.ErrUnavailable`,\swhich\sthe\srouter\salready\smaps\sto\s503.\n4.\s**`job`\stable\sin\sOLTP**\s—\sid,\srepo,\skind,\sstate,\squeued/started/finished,\sresult\sref,\serror.\sModelled\son\s`ci_run`,\sincluding\sits\sretention\sproblem\s(see\s8d5aa739f8:\s`ci_run`\sgrows\swithout\sbound\s—\sthe\sjob\stable\smust\snot\srepeat\sthat).\n5.\s**`job.list`\s/\s`job.get`\sops**,\sa\sjob\spage,\sand\sSSE\sfor\slive\sstate.\sRenders\sat\sload,\srefresh\sworks\swithout\sJS.\n6.\s**Metrics\son\s`/fleet`**\s—\sper-lane\sdepth,\sin-flight,\swait\spercentiles,\ssheds.\sThis\sis\sthe\s"do\swe\sneed\sanother\snode"\snumber,\sand\sit\sdoes\snot\sexist\stoday\sin\sany\sform.\n\n##\sOrder\n\nThe\sadmission\scontrol\sis\sworth\smore\sthan\sthe\sjob\sUI\sand\sis\smuch\ssmaller:\sbounding\sconcurrency\sfixes\sthe\sDoS\sand\sthe\sdegradation,\swhile\sthe\squeued/async\ssurface\smakes\sit\slegible.\sSuggested\ssequence:\n\n1.\sBound\s`archive.get`\simmediately\s—\sthe\slive\sexposure.\n2.\s`internal/work`\swith\sthe\sthree\slanes,\swired\sinto\sthe\szit\sread\spath\sand\sthe\swrite\spath.\n3.\sLane\smetrics\son\s`/fleet`.\n4.\s`job`\stable,\sops,\sand\sthe\sasync\sUI\sfor\s`bulk`.\n\nSteps\s1–2\sremove\sthe\sfailure\smode;\s3–4\smake\sit\sobservable,\swhich\sis\sthe\spoint\sof\sthe\sexercise.\n
J status Open
J title Bound\sand\squeue\sexpensive\swork:\sadmission\scontrol,\sjob\ssurface,\slane\smetrics
K 8152617b9986ca2663c953bb069b15b71e2407bb
U dmestas
Z 51134966c340e7f8ad3884d3245e6e0e