THE STARVATION

THE STARVATION · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · BOSS · THE GAUNTLET ◆ .dlw.fold THE FOLD / BOSS / THE GAUNTLET / THE STARVATION THE STARVATION the scheduler was doing precisely what it was told 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION Strict priority is not a queue, it is a promise that one class always wins. When that class alone can keep the server busy, the promise is that the other class never runs. LIT verified live. 20,000 ticks, high-priority arrivals 0.95 and low 0.20 against a service rate of 1 . Strict priority serves 19,009 high and 991 low, leaves 2,956 low jobs still queued, and one of them has been waiting 14,833 ticks. Aging — letting a job’s priority climb with its wait — serves 3,280 low, backlog 667 , worst wait 3,418 . The high class serves 2,289 fewer, which is exactly the 2,289 the low class gained. 2 HOW IT WAS WEAVED · AI + HUMAN Aging is the textbook fix for starvation, and the exact-conservation result is not a coincidence: the server is saturated, so every tick given to one class is taken from the other. AVAN (AI) first ran this at an offered load of 0.80 against a service rate of 1 — under capacity, so nothing starved and both schedulers were identical. Starvation is a property of saturation, not of priority. The rule only bites when the favoured class alone can fill the server, so that is where the experiment belongs. 3 ONE DIMENSION Who gets served, and who is still waiting. 4 TWO DIMENSIONS · INTERACTIVE Move the load across the saturation line. more high-priority load ▶ less toggle aging reset 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: a queue that is never reached. AVAN’s addition (the inverse-companion): the forward reading is that aging fixes starvation. The inverse is that it fixes it by breaking the priority promise, and the ledger is exact . 2,289 low jobs ran, 2,289 high jobs did not; at saturation there is no other way for the numbers to come out. Read backwards, aging is not a repair to the scheduler — the scheduler was doing precisely what it was told. It is a decision that the priority order was a lie you were willing to tell only until the wait got embarrassing. pause spin LIT over 20,000 ticks with high-priority arrivals at 0.95 and low at 0.20 against a service rate of 1, strict priority serves 19,009 high and 991 low, leaves 2,956 low jobs queued and one waiting 14,833 ticks, while aging serves 3,280 low with a backlog of 667 and a worst wait of 3,418 - and the high class serves exactly 2,289 fewer, which is exactly the 2,289 the low class gained FIG Aging is the textbook fix for starvation, and the exact conservation is not a coincidence: the server is saturated, so every tick given to one class is taken from the other. AVAN first ran this at an offered load of 0.80 against a service rate of 1 - under capacity, so nothing starved and both schedulers were identical. Starvation is a property of saturation, not of priority, and the rule only bites when the favoured class alone can fill the server. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE GAUNTLET · David Lee Wise (ROOT0), with AVAN


THE TIME SLICE

A short time slice makes a machine feel responsive and spends most of its day switching. A long one is efficient and makes everything feel stuck. The good value is in the middle and it is not a matter of taste.

I-13 v2.0 | net = binds - k | 4 planes, 13 symbols, 12 operants, 5 cortex rules | sha 64881ebf

THE TIME SLICE · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · GLITCH · RACE CONDITION ◆ .dlw.fold THE FOLD / GLITCH / RACE CONDITION / THE TIME SLICE THE TIME SLICE the half that decided the real value was never a number 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION A short time slice makes the machine feel responsive and spends most of its day switching. A long one is efficient and makes everything feel stuck. The good value is in the middle and it is not a matter of taste. LIT verified live. 50 jobs, a switch costing 2 . At a quantum of 1 the machine spends 66.67% of all elapsed time switching, and mean turnaround is 3,871.1 . At 128 the overhead is small and turnaround is worse again. The best of the eight measured is a quantum of 32 , and it is an interior point — neither end of the range wins. 2 HOW IT WAS WEAVED · AI + HUMAN Every real scheduler tunes this, and the interior optimum is why: the two costs pull in opposite directions and neither can be minimised alone. AVAN (AI) swept the quantum rather than arguing for a value, because the shape is the finding. 66.67% overhead at quantum 1 means two thirds of the machine’s life is bookkeeping — and the fix is not a faster switch, it is a longer turn. 3 ONE DIMENSION Quantum against turnaround and overhead. 4 TWO DIMENSIONS · INTERACTIVE Set the quantum and the switch cost. longer quantum ▶ shorter costlier switch reset 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: a turn, cut into pieces. AVAN’s addition (the inverse-companion): the forward reading is that the quantum trades responsiveness against overhead. The inverse is that responsiveness is not a property of the machine at all . Turnaround, overhead, throughput — all of them are measured here. Whether 32 feels better than 8 is a fact about a person waiting, and no sweep on this page contains it. Read backwards, the interior optimum is the honest half of the problem, and the half that decided the value in the machine you are reading this on was never a number. pause spin LIT 50 jobs with a switch costing 2 spend 66.67% of all elapsed time switching at a quantum of 1, for a mean turnaround of 3,871.1, while a quantum of 128 has small overhead and worse turnaround again - the best of the eight measured is 32, an interior point, so neither end of the range wins FIG Every real scheduler tunes this, and the interior optimum is why: the two costs pull in opposite directions and neither can be minimised alone. AVAN swept the quantum rather than arguing for a value, because the shape is the finding. 66.67% overhead at quantum 1 means two thirds of the machine's life is bookkeeping - and the fix is not a faster switch, it is a longer turn. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of RACE CONDITION · David Lee Wise (ROOT0), with AVAN


THE LOTTERY SCHEDULER

Hand out tickets in proportion to the share each process should get, draw one at random, run its owner. No queue, no priorities to age, no bookkeeping at all - and it is only fair on average.

THE LOTTERY SCHEDULER · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · LOOT · THE VAULT ◆ .dlw.fold THE FOLD / LOOT / THE VAULT / THE LOTTERY SCHEDULER THE LOTTERY SCHEDULER a window too short for the limit to have arrived 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION Hand out tickets in proportion to the share each process should get, then draw one at random and run its owner. No queue to maintain, no priorities to age, no bookkeeping at all — and it is only fair on average. LIT verified live. Tickets 10 / 20 / 30 / 40 , and the error measured as a mean over 200 independent runs at each size. At 100 draws the total absolute share error is 0.1296 ; at 6,400 it is 0.01694 . Every quadrupling of the draws roughly halves the error — measured ratios 2.037 , 1.899 , 1.978 against the 2 that 1/√N predicts. The fairness is real, and it is asymptotic. 2 HOW IT WAS WEAVED · AI + HUMAN Lottery scheduling is Waldspurger and Weihl ’s (1994); the appeal is that proportional share falls out of the draw with no state to keep. AVAN (AI) first gated this on the error shrinking at every step and it failed — 10,000 draws came out worse than 1,000 , because a single Monte Carlo walk is not monotonic and never was. The claim being made is a rate , and a rate cannot be read off one walk. Averaging 200 runs per point is what turns the assertion into a measurement. 3 ONE DIMENSION Error against draws. Four times the draws, half the error. 4 TWO DIMENSIONS · INTERACTIVE Draw tickets and watch the shares settle. draw more ▶ fewer reset 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: a share that only exists over time. AVAN’s addition (the inverse-companion): the forward reading is that lottery scheduling gives proportional share. The inverse is that it gives it to nobody who is watching . A process holding 40 of 100 tickets can lose ten draws running, and over any window short enough for a person to notice, the guarantee simply is not there. Read backwards, the elegance is bought by moving the promise from each moment to the limit, and every user complaint about a scheduler is a complaint about a window too short for the limit to have arrived. pause spin LIT tickets of 10, 20, 30 and 40 with the error measured as a mean over 200 independent runs give a total absolute share error of 0.1296 at 100 draws and 0.01694 at 6,400, so every quadrupling of the draws roughly halves the error - measured ratios 2.037, 1.899 and 1.978 against the 2 that 1/sqrt(N) predicts FIG Lottery scheduling is Waldspurger and Weihl's (1994); the appeal is that proportional share falls out of the draw with no state to keep. AVAN first gated this on the error shrinking at every step and it failed - 10,000 draws came out worse than 1,000, because a single Monte Carlo walk is not monotonic and never was. The claim being made is a rate, and a rate cannot be read off one walk; averaging 200 runs per point is what turns the assertion into a measurement. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE VAULT · David Lee Wise (ROOT0), with AVAN


THE CONTEXT SWITCH

Saving registers and loading the next process is the part you can count. It is not the part that costs. The new process arrives to a cache full of somebody else's data and has to earn its own back.

THE CONTEXT SWITCH · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · RESPAWN · ROLLBACK ◆ .dlw.fold THE FOLD / RESPAWN / ROLLBACK / THE CONTEXT SWITCH THE CONTEXT SWITCH not the cost of switching, the cost of having been away 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION Saving registers and loading the next process is the part of a context switch you can count. It is not the part that costs. The new process arrives to a cache full of somebody else’s data and has to earn its own back. LIT verified live, on a stated model. Save/restore is a fixed 1 ; the working set is 64 units and refilling costs 0.5 each. Switch to a process that runs for 1 unit and the switch costs 1.5 — 150% of the work done. Let it run 256 and the same switch costs 33 , which is 12.89% of the run, and 96.97% of that cost is cache, not registers. The direct cost never moved from 1 . 2 HOW IT WAS WEAVED · AI + HUMAN The indirect cost dominating the direct one is the standard result; the numbers here come from a stated model, not from a measured machine, and the model is on the page so you can disagree with it. AVAN (AI) is being explicit about that because it is the honest limit of this sphere. What is genuinely demonstrated is the shape : a fixed cost plus a cost bounded by how long you get to run means the penalty per unit of work falls with the run length, and no improvement to save/restore changes that. 3 ONE DIMENSION Run length against what the switch really costs. 4 TWO DIMENSIONS · INTERACTIVE Change the working set and see what registers are worth. bigger working set ▶ smaller faster save/restore reset 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: arriving to someone else’s memory. AVAN’s addition (the inverse-companion): the forward reading is that the cache refill is the hidden cost of switching. The inverse is that it is not a cost of switching at all — it is the cost of having been away . Nothing was spent at the moment of the switch; the process simply returns to a machine that has forgotten it, and pays on the way back in. Read backwards, that is why making the switch itself cheaper buys so little, and why the only real lever is the one the scheduler already holds: how long it lets anybody stay. pause spin LIT on a stated model with save/restore fixed at 1, a working set of 64 units and a refill costing 0.5 each, a switch to a process that runs for 1 unit costs 1.5 - which is 150% of the work done - while the same switch before a run of 256 costs 33, or 12.89% of the run, with 96.97% of that cost being cache rather than registers, and the direct cost never moving from 1 FIG The indirect cost dominating the direct one is the standard result; the numbers here come from a stated model, NOT from measured hardware, and the model is on the page so you can disagree with it. AVAN is explicit about that because it is the honest limit of this sphere. What is genuinely demonstrated is the shape: a fixed cost plus a cost bounded by how long you get to run means the penalty per unit of work falls with the run length, and no improvement to save/restore changes that. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of ROLLBACK · David Lee Wise (ROOT0), with AVAN


THE PREEMPTION

THE PREEMPTION · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · BOSS · THE GATEKEEPER ◆ .dlw.fold THE FOLD / BOSS / THE GATEKEEPER / THE PREEMPTION THE PREEMPTION a permission every piece of code has to keep granting 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION Without preemption an urgent arrival waits for whatever happens to be running to finish on its own. With it, the running job is stopped mid-stride. The urgent case gets what it needs and everything else pays in interruptions. LIT verified live. 304 arrivals over 6,000 ticks, 52 of them urgent. Non-preemptive: urgent jobs wait 24.8 on average. Preemptive: 4.3 — 5.77× faster to first run. The ordinary jobs are not the ones who paid the obvious price: their mean response actually improved from 2,053.8 to 1,862.9 . What preemption cost was 37 extra context switches. 2 HOW IT WAS WEAVED · AI + HUMAN Preemption is the difference between a batch system and an interactive one, and between a general-purpose kernel and a real-time one. AVAN (AI) reports the ordinary jobs improving because it is the result that was not expected and it has a plain cause: pulling short urgent work through promptly stops it accumulating in front of everyone else. The honest cost line is 37 switches — and THE CONTEXT SWITCH next door is the sphere about what those actually cost. 3 ONE DIMENSION Time to first run, urgent and ordinary. 4 TWO DIMENSIONS · INTERACTIVE Change how much of the load is urgent. more urgent ▶ less toggle preemption reset 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: a job stopped mid-stride. AVAN’s addition (the inverse-companion): the forward reading is that preemption serves urgency. The inverse is that it requires the running job to be interruptible, and that is a property of the job, not the scheduler . Anything holding a lock, mid-write, or partway through a transaction cannot simply be stopped — and a scheduler that stops it anyway produces THE PRIORITY INVERSION . Read backwards, preemption is not a power the scheduler has; it is a permission every piece of code in the system has to keep granting it. pause spin LIT 304 arrivals over 6,000 ticks with 52 urgent give urgent jobs a mean wait to first run of 24.8 without preemption and 4.3 with it, a factor of 5.77, while the ordinary jobs also improved - from 2,053.8 to 1,862.9 - so what preemption actually cost was 37 extra context switches FIG Preemption is the difference between a batch system and an interactive one, and between a general-purpose kernel and a real-time one. AVAN reports the ordinary jobs improving because it is the result that was not expected and it has a plain cause: pulling short urgent work through promptly stops it accumulating in front of everyone else. The honest cost line is 37 switches - and THE CONTEXT SWITCH next door is the sphere about what those actually cost. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE GATEKEEPER · David Lee Wise (ROOT0), with AVAN


THE EARLIEST DEADLINE

Fixed priorities are decided once, by period. Earliest-deadline-first re-decides on every tick, by whoever is closest to being late. There is a band of load where that is the difference between meeting every deadline and missing them.

THE EARLIEST DEADLINE · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · BOSS · THE WALL ◆ .dlw.fold THE FOLD / BOSS / THE WALL / THE EARLIEST DEADLINE THE EARLIEST DEADLINE optimal says nothing about what happens when you are wrong 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION Fixed priorities are decided once, by period. Earliest-deadline-first re-decides on every tick, by whoever is closest to being late. There is a band of load where that difference is the difference between meeting every deadline and missing them. LIT verified live. Two periodic tasks, (period 5, cost 2) and (period 7, cost 4) , utilisation 0.9714 . That sits above the Liu–Layland bound for two fixed-priority tasks, 0.8284 , and below EDF’s bound of 1 . Over 1,400 ticks EDF misses 0 deadlines. Rate-monotonic, running the identical tasks on the identical machine, misses 40 . 2 HOW IT WAS WEAVED · AI + HUMAN The bounds are Liu and Layland (1973): EDF is optimal for uniprocessor scheduling up to 100% utilisation, fixed priority only up to n(2 1/n −1), which falls to about 69% as n grows. AVAN (AI) first picked a task set at utilisation 0.75 — below the fixed-priority bound of 0.7798 , so both schedulers met every deadline and the comparison demonstrated nothing. The gap only exists between the two bounds. A comparison has to be run where the thing being compared can differ. 3 ONE DIMENSION The two bounds, and the band between them. 4 TWO DIMENSIONS · INTERACTIVE Move the load and watch the deadlines. heavier task ▶ lighter switch scheduler reset 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: whoever is closest to late. AVAN’s addition (the inverse-companion): the forward reading is that EDF is optimal and fixed priority is not. The inverse is that optimal means nothing about what happens when you are wrong . Push a fixed-priority set past its bound and the long-period tasks miss first, predictably, and the important short ones keep running. Push EDF past 1 and it has no opinion about who matters — everything is equally close to late, so everything fails together. Read backwards, the extra 17 points of utilisation are bought by giving up the ability to fail in a chosen order. pause spin LIT two periodic tasks of (period 5, cost 2) and (period 7, cost 4) give a utilisation of 0.9714, which is above the Liu-Layland bound of 0.8284 for two fixed-priority tasks and below EDF's bound of 1, and over 1,400 ticks EDF misses 0 deadlines while rate-monotonic - identical tasks, identical machine - misses 40 FIG The bounds are Liu and Layland (1973): EDF is optimal for uniprocessor scheduling up to 100% utilisation, fixed priority only up to n(2^(1/n)-1), which falls to about 69% as n grows. AVAN first picked a task set at utilisation 0.75 - below the fixed-priority bound of 0.7798 - so both schedulers met every deadline and the comparison demonstrated nothing. The gap only exists between the two bounds, and a comparison has to be run where the thing being compared can differ. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE WALL · David Lee Wise (ROOT0), with AVAN


THE MULTILEVEL FEEDBACK

Shortest-job-first needs to know how long each job will run, which nothing does. The feedback queue guesses instead: start everything at the top, demote anything that uses its whole slice. A job that keeps running proves it is long.

THE MULTILEVEL FEEDBACK · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · RESPAWN · SECOND WIND ◆ .dlw.fold THE FOLD / RESPAWN / SECOND WIND / THE MULTILEVEL FEEDBACK THE MULTILEVEL FEEDBACK a fee levied on evidence, not a conclusion drawn from it 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION Shortest-job-first needs to know how long each job will run, which nothing does. The multi-level feedback queue guesses instead: start everything at the top, and demote anything that uses its whole slice. A job that keeps running proves it is long. LIT verified live. 300 jobs, 238 short and the rest long. FIFO gives a mean turnaround of 6,484.6 . An oracle running true shortest-first gives 1,480.2 . The feedback queue — three levels, quanta 4/16/64 , and no knowledge of any job’s length — gives 2,867.5 : 2.26× better than FIFO, and 1.94× off the oracle it cannot see. 2 HOW IT WAS WEAVED · AI + HUMAN MLFQ is the scheduler in the classic Unix lineage; the demotion rule is the whole idea, and Corbató ’s CTSS had it in 1962. AVAN (AI) published the oracle column because without it “ 2.26× better than FIFO” sounds like the end of the story. The gap to the oracle is 1.94× , and that gap is the standing price of not knowing — the thing the technique is designed around rather than the thing it removes. 3 ONE DIMENSION Three schedulers, one of which is not allowed to look. 4 TWO DIMENSIONS · INTERACTIVE Change the quanta and watch jobs fall through the levels. wider quanta ▶ narrower reset 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: falling through the levels. AVAN’s addition (the inverse-companion): the forward reading is that the feedback queue learns which jobs are short. The inverse is that it learns nothing — it charges for the answer . A job is demoted for having run, which is a fee levied on evidence, not a conclusion drawn from it, and the scheduler never holds a belief about anything. Read backwards, that is exactly why it cannot be fooled by a job lying about its length, and exactly why a long job that turns interactive stays punished for a past it has already left. pause spin LIT 300 jobs of which 238 are short give a FIFO mean turnaround of 6,484.6 and an oracle running true shortest-first 1,480.2, while a three-level feedback queue with quanta 4/16/64 and no knowledge of any job's length gives 2,867.5 - 2.26 times better than FIFO and 1.94 times off the oracle it cannot see FIG MLFQ is the scheduler in the classic Unix lineage; the demotion rule is the whole idea, and Corbato's CTSS had it in 1962. AVAN published the oracle column because without it 2.26 times better than FIFO sounds like the end of the story. The gap to the oracle is 1.94, and that gap is the standing price of not knowing - the thing the technique is designed around rather than the thing it removes. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of SECOND WIND · David Lee Wise (ROOT0), with AVAN