interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / node / schedpol-test.om

1314 lines · 38973 bytes Raw Blame History
1note Concatenate after transport.om, pool.om, super.om and sched.om. CPU-only
2note acceptance of the resource-aware selection policy (P-DRA-14) with real
3note forked workers: impossible requests, the capacity invariant under churn,
4note ready order, the head-of-line scenarios of the reference pump
5note (aien-sovereign-core-mv spark-harness scheduler/core.rs Core::pump),
6note starvation under repeated small arrivals, admission tickets, lease
7note expiry and cancellation of a reserved job.
8note After every creator step the test checks that no kind is used beyond its
9note capacity and that the use equals the needs of the jobs holding them.
10note Argument "fifo" runs policy 0, "noreserve" policy 1 with the bypass
11note budget out of reach: the negative controls. No GPU, model or network.
12text pok "PASS node schedpol\n"
13text pst "schedpol events="
14text pex " examined="
15text pas " assigned="
16text phol " hol_stops="
17text pbyp " bypasses="
18text pres " reservations="
19text pnl "\n"
20text ptr "schedpol goal trace "
21text psp " "
22text pw1 "schedpol hol witness head="
23text pw2 " fits_behind="
24text pw3 " free_cpu="
25text pw4 " idle_worker="
26global ptc long 1
27note Mode: 0 default policy, 1 fifo, 2 noreserve, 3 goal (policy 2).
28global ptm ulong 1
29note Step-bound snapshot (pt_snap): event count, candidate reads,
30note maintenance reads, assigned, cursor, window scans.
31global ptb ulong 6
32note Phase G trace: ids in review order.
33global ptt ulong 16
34global ptn ulong 1
35note Value-read bound baseline: stats 38, 32, 33 at the last check.
36global ptv ulong 3
37
38fn pt_ok ok bool code int to void
39if not ok
40exit code
41end
42end
43
44fn pt_num v ulong to void
45d = new uchar 20 0
46x = v
47k = ulong 20
48for i ulong 20
49k = sub k 1
50put d k uchar add rem x 10 48
51x = div x 10
52if eq x 0
53break
54end
55end
56r = write 1 d k sub 20 k
57end
58
59note Packed request: cpu slots, memory MiB, inference slots, kind 3.
60fn pt_req cpu ulong mem ulong inf ulong x ulong to ulong
61ret or or cpu shl mem 16 or shl inf 32 shl x 48
62end
63
64note Worker: run assignment q for the milliseconds in the low four decimal
65note digits of its job id, then report outcome id+1 and 8 bytes. 0 done,
66note 2 stopped, 3 creator gone, 4 wait error, 5 report refused.
67fn pt_run c long w ulong q ulong to int
68buf = new uchar 4096 0
69id = sc_cell w 8
70dl = add ulong monons mul rem id 10000 1000000
71for t ulong 1000000
72now = ulong monons
73if ge now dl
74break
75end
76r = sched_wwait c w long sub dl now
77if eq r 2
78ret 2
79end
80if eq r 3
81ret 3
82end
83if lt r 0
84ret 4
85end
86end
87if ne sched_wdone w q add id 1 buf 8 0
88ret 5
89end
90ret 0
91end
92
93fn pt_worker w ulong to int
94c = get ptc 0
95for it ulong 1000000000
96q = sched_wjob w
97if gt q 0
98r = pt_run c w q
99if eq r 2
100ret 0
101end
102if ne r 0
103ret add 60 r
104end
105continue
106end
107r = sched_wwait c w neg long 1
108if eq r 2
109ret 0
110end
111if eq r 3
112ret 41
113end
114if lt r 0
115ret 43
116end
117end
118ret 45
119end
120
121fn pt_spawn c long w ulong to bool
122p = sup_spawn c w
123if eq p 0
124exit pt_worker w
125end
126ret gt p 0
127end
128
129note Fresh pool for w workers (spawned), admission limit a, review limit rl,
130note capacities caps. Exits with code on any refusal.
131fn pt_setup w ulong a ulong rl ulong caps ulong code int to long
132c = pool_new 4 w
133pt_ok gt c 0 code
134put ptc 0 c
135pt_ok eq sup_init c 0 code
136pt_ok eq sched_new c a rl 0 code
137pt_ok eq sched_cap caps 0 code
138put ptv 0 sched_stat 38
139put ptv 1 sched_stat 32
140put ptv 2 sched_stat 33
141if eq get ptm 0 1
142pt_ok eq sched_policy 0 64 64 4 1000 0 code
143end
144if eq get ptm 0 2
145pt_ok eq sched_policy 1 64 64 65535 1000 0 code
146end
147if eq get ptm 0 3
148pt_ok eq sched_policy 2 64 64 4 1000 0 code
149end
150for i ulong w bound 64
151pt_ok pt_spawn c i code
152end
153ret c
154end
155
156fn pt_down c long code int to void
157pt_ok ge sched_stop c 2000000000 0 code
158sup_closeall
159pt_ok eq sched_free 0 code
160pt_ok eq pool_free c 0 code
161end
162
163note The capacity invariant: of each kind the use is at most the capacity
164note and equals the sum of the needs of the jobs that hold resources; only
165note a running job holds them, and every running job whose worker has not
166note reported done holds them.
167fn pt_inv code int to void
168for j ulong 64
169if eq get sjst j 3
170w = get sjw j
171if ne sc_cell w 64 get scseq w
172pt_ok eq get sjheld j 1 code
173end
174end
175end
176for k ulong 4
177s = ulong 0
178for j ulong 64
179if eq get sjheld j 1
180pt_ok eq get sjst j 3 code
181s = add s sp_need get sjneed j k
182end
183end
184pt_ok eq get suse k s code
185pt_ok le get suse k get scap k code
186end
187end
188
189note One creator step of up to 10 ms, then the invariant and the scan
190note bounds since the last step. An event makes at most one pick more than
191note it assigns, so candidate reads are at most (assigned + events) x
192note (window + 1), the reserved probe included, plus one proposal probe per
193note pick under policy 2, or x 64 under FIFO (policy 0), 9; maintenance reads
194note at most 64 per event, 14; the cursor moved by exactly the window per
195note window scan, mod 64, 15 (the traversal witness: window scans cover
196note consecutive windows, so ceil(64/win) of them examine every slot); value
197note reads at most 64 per rescoring plus 128 per job scored, 8.
198fn pt_step c long code int to void
199pt_snap
200r = sched_step c 10000000
201pt_ok ge r 0 code
202pt_inv code
203pt_check
204end
205
206note Snapshot the counters the step bounds compare against (ptb).
207fn pt_snap to void
208put ptb 0 sched_stat 2
209put ptb 1 sched_stat 3
210put ptb 2 sched_stat 13
211put ptb 3 sched_stat 4
212put ptb 4 sched_stat 28
213put ptb 5 sched_stat 14
214end
215
216note The bounds since pt_snap (exits 9, 14, 15, 8).
217fn pt_check to void
218w = add sched_stat 25 1
219if eq sched_stat 24 0
220w = ulong 64
221end
222if eq sched_stat 24 2
223w = add w 1
224end
225ev = sub sched_stat 2 get ptb 0
226lim = mul add sub sched_stat 4 get ptb 3 ev w
227pt_ok le sub sched_stat 3 get ptb 1 lim 9
228pt_ok le sub sched_stat 13 get ptb 2 mul ev 64 14
229pt_cursor get ptb 4 get ptb 5
230pt_vbound
231end
232
233note Resume dispatch (it dispatches at once) inside the step bounds.
234fn pt_resume c long to void
235pt_snap
236k = sched_pause c false
237pt_check
238end
239
240note The cursor moved by the window once per window scan since (u0, s0).
241fn pt_cursor u0 ulong s0 ulong to void
242d = mul sched_stat 25 sub sched_stat 14 s0
243pt_ok eq sched_stat 28 rem add u0 d 64 15
244end
245
246note The value-read bound since the last call (phase checks, exit 8).
247fn pt_vbound to void
248v = sched_stat 38
249lim = add mul sub sched_stat 32 get ptv 1 64 mul sub sched_stat 33 get ptv 2 128
250pt_ok le sub v get ptv 0 lim 8
251put ptv 0 v
252put ptv 1 sched_stat 32
253put ptv 2 sched_stat 33
254end
255
256note Step until job j is in a state in lo..hi, up to ms. True when reached.
257fn pt_until c long j ulong lo ulong hi ulong ms ulong code int to bool
258dl = add ulong monons mul ms 1000000
259for t ulong 1000000
260s = get sjst j
261if and ge s lo le s hi
262ret true
263end
264if ge ulong monons dl
265ret false
266end
267pt_step c code
268end
269ret false
270end
271
272note Review every job in review whose outcome is its id + 1.
273fn pt_review code int to ulong
274n = ulong 0
275for j ulong 64
276if eq get sjst j 4
277pt_ok eq sched_review j long add get sjid j 1 code
278n = add n 1
279end
280end
281ret n
282end
283
284note Step and review until n jobs were reviewed, up to ms.
285fn pt_drain c long n ulong ms ulong code int to void
286dl = add ulong monons mul ms 1000000
287k = ulong 0
288for t ulong 1000000
289k = add k pt_review code
290if ge k n
291ret
292end
293pt_ok lt ulong monons dl code
294pt_step c code
295end
296exit code
297end
298
299fn pt_admit id ulong deps ulong req ulong code int to ulong
300j = sched_admitr id deps 0 req
301pt_ok ge j 0 code
302ret ulong j
303end
304
305note Phase C: a request beyond the capacity of any kind is refused (-8) and
306note counted; lowering a capacity below an admitted job's need, or below
307note the use of two running jobs that each fit it alone, is refused and
308note changes nothing.
309fn pt_impossible to void
310c = pt_setup 2 8 8 pt_req 4 1024 1 8 30
311pt_ok eq sched_admitr 1 0 0 pt_req 5 0 0 0 neg long 8 31
312pt_ok eq sched_admitr 2 0 0 pt_req 1 1025 0 0 neg long 8 32
313pt_ok eq sched_admitr 3 0 0 pt_req 0 0 2 0 neg long 8 33
314pt_ok eq sched_stat 7 3 34
315a = pt_admit 4 0 pt_req 3 0 0 0 35
316pt_ok eq sched_cap pt_req 2 1024 1 8 neg long 8 36
317pt_ok eq sched_stat 16 4 37
318pt_ok eq sched_cancel a 1 38
319pt_ok eq sched_cap pt_req 2 1024 1 8 0 39
320pt_ok eq sched_stat 16 2 40
321pt_ok eq sched_cap pt_req 4 1024 1 8 0 130
322p = pt_admit 130400 0 pt_req 2 0 0 0 130
323q = pt_admit 140400 0 pt_req 2 0 0 0 130
324pt_ok pt_until c p 3 3 2000 130 130
325pt_ok pt_until c q 3 3 2000 130 130
326pt_ok eq sched_cap pt_req 3 1024 1 8 neg long 8 131
327pt_ok eq sched_stat 16 4 132
328pt_drain c 2 3000 133
329pt_ok eq sched_cap pt_req 3 1024 1 8 0 134
330pt_down c 41
331end
332
333note Phase D: 12 jobs with mixed CPU, memory and inference needs on three
334note workers, capacities 4 CPU, 1024 MiB, 1 inference slot. Every job runs
335note once and returns its outcome; the invariant holds at every step and
336note every resource is free at the end.
337fn pt_churn to void
338c = pt_setup 3 16 8 pt_req 4 1024 1 0 42
339for i ulong 12
340cpu = add rem i 3 1
341mem = mul add rem i 6 1 100
342inf = rem i 2
343id = add mul add i 1 10000 add 30 mul rem i 4 15
344j = pt_admit id 0 pt_req cpu mem inf 0 43
345end
346pt_drain c 12 10000 44
347for k ulong 4
348pt_ok eq get suse k 0 45
349end
350pt_ok eq sched_count 1 6 0 46
351pt_ok eq sched_stat 4 12 47
352pt_down c 48
353end
354
355note Some running job whose worker has reported done (its result waits
356note for review room).
357fn pt_held to bool
358for j ulong 64
359if eq get sjst j 3
360w = get sjw j
361if eq sc_cell w 64 get scseq w
362ret true
363end
364end
365end
366ret false
367end
368
369note Phase V: release while review is full. Review limit 1, two workers,
370note 2 CPU: j1 and j2 (1 CPU, 50 ms) both finish; one enters review, the
371note other's result waits for room, yet both CPUs are free at once and j3
372note (2 CPU) runs before anything is reviewed.
373fn pt_release to void
374c = pt_setup 2 8 1 pt_req 2 1024 1 8 120
375j1 = pt_admit 150050 0 pt_req 1 0 0 0 120
376j2 = pt_admit 160050 0 pt_req 1 0 0 0 120
377dl = add ulong monons 2000000000
378for t ulong 1000000
379if eq sched_count 4 4 1
380if pt_held
381break
382end
383end
384pt_ok lt ulong monons dl 121
385pt_step c 121
386end
387note The done report may land after the last collect: one more step
388note collects it (review stays full, so nothing else changes).
389pt_step c 121
390pt_ok eq get suse 0 0 122
391j3 = pt_admit 170050 0 pt_req 2 0 0 0 123
392pt_ok pt_until c j3 3 4 2000 123 124
393pt_drain c 3 3000 125
394pt_down c 126
395end
396
397note Phase F: ready order. With one worker, x is admitted first waiting on
398note topic 8 and y second ready at once; then topic 8 is published. FIFO
399note (policy 0) serves the job that became ready first, y; fair fitting
400note serves the job admitted first, x (waiting age counts from admission).
401fn pt_order to void
402buf = new uchar 4096 0
403c = pt_setup 1 8 8 pt_req 4 1024 1 8 50
404x = pt_admit 60050 8 0 51
405y = pt_admit 70050 0 0 52
406pt_snap
407pt_ok gt sched_publish c 8 buf 16 0 53
408pt_check
409if eq sched_stat 24 0
410pt_ok eq get sjst y 3 54
411pt_ok eq get sjst x 2 55
412else
413pt_ok eq get sjst x 3 54
414pt_ok eq get sjst y 2 55
415end
416pt_drain c 2 3000 56
417pt_down c 57
418end
419
420note Witness of a head-of-line block, read with no step in between: a runs
421note unfinished holding its need, the head h is ready and does not fit, x
422note is ready and fits, a live worker is idle, and dispatch stopped at the
423note head at least once since h0 (codes code..code+4 when not).
424fn pt_witness c long a ulong h ulong x ulong h0 ulong code int to void
425w = get sjw a
426pt_ok eq get sjst a 3 code
427pt_ok ne sc_cell w 64 get scseq w code
428pt_ok eq get sjheld a 1 code
429pt_ok eq get sjst h 2 add code 1
430pt_ok not sp_fits get sjneed h 0 add code 1
431pt_ok eq get sjst x 2 add code 2
432pt_ok sp_fits get sjneed x 0 add code 2
433i = sp_idle mapget c 48 8
434pt_ok lt i 64 add code 3
435pt_ok gt sched_stat 8 h0 add code 4
436r = write 1 pw1 0 len pw1
437pt_num get sjid h
438r = write 1 pw2 0 len pw2
439pt_num get sjid x
440r = write 1 pw3 0 len pw3
441pt_num sp_free 0
442r = write 1 pw4 0 len pw4
443pt_num i
444r = write 1 phol 0 len phol
445pt_num sub sched_stat 8 h0
446r = write 1 pnl 0 1
447end
448
449note Phase A: the blocked head. a (3 CPU, 800 ms) runs; then b (2 CPU,
450note cannot fit) and c (1 CPU, fits) arrive with no dependency. The target:
451note c runs while a still runs and b waits (0). When c has not run within
452note 400 ms, the witness is checked and printed and the phase returns 11:
453note c stayed idle behind b although a CPU and a worker were free.
454fn pt_blocked to int
455c = pt_setup 3 8 8 pt_req 4 1024 1 8 10
456a = pt_admit 10800 0 pt_req 3 0 0 0 10
457pt_ok pt_until c a 3 3 2000 10 10
458b = pt_admit 20050 0 pt_req 2 0 0 0 10
459x = pt_admit 30050 0 pt_req 1 0 0 0 10
460h0 = sched_stat 8
461v = int 0
462if pt_until c x 3 4 400 10
463pt_ok eq get sjst a 3 12
464pt_ok eq get sjst b 2 13
465else
466pt_witness c a b x h0 12
467v = int 11
468end
469pt_drain c 3 5000 17
470pt_down c 18
471ret v
472end
473
474note Phase B: a second head-of-line case, after the pump's queue-of-two
475note scenario (the bounded queue itself is not modelled: every admitted
476note job is in the table). a (3 CPU, 800 ms) runs, b and d (2 CPU) cannot
477note fit, e (1 CPU) fits. Target: e runs while a still runs (0); else the
478note witness and 21.
479fn pt_exclude to int
480c = pt_setup 3 8 8 pt_req 4 1024 1 8 20
481a = pt_admit 10800 0 pt_req 3 0 0 0 20
482pt_ok pt_until c a 3 3 2000 20 20
483b = pt_admit 20050 0 pt_req 2 0 0 0 20
484d = pt_admit 40050 0 pt_req 2 0 0 0 20
485e = pt_admit 50050 0 pt_req 1 0 0 0 20
486h0 = sched_stat 8
487v = int 0
488if pt_until c e 3 4 400 20
489pt_ok eq get sjst a 3 22
490else
491pt_witness c a b e h0 22
492v = int 21
493end
494pt_drain c 4 5000 27
495pt_down c 28
496ret v
497end
498
499note Phase S: starvation under repeated small arrivals. Three workers, 4
500note CPU. Small jobs (1 CPU) start staggered (100, 200, 300 ms), and each
501note that finishes is replaced by one of 300 ms, so the small jobs never
502note all end together; big (4 CPU, 50 ms) needs every CPU free. The target:
503note big runs within 4 s. 61 means it never did: the small jobs kept the
504note CPU partly busy (the "noreserve" control).
505fn pt_starve to void
506c = pt_setup 3 16 8 pt_req 4 1024 1 8 60
507for i ulong 3
508j = pt_admit mul add i 1 100100 0 pt_req 1 0 0 0 60
509end
510s = ulong 4
511g = pt_admit 90050 0 pt_req 4 0 0 0 60
512dl = add ulong monons 4000000000
513ok = false
514for t ulong 1000000
515if ge get sjst g 3
516ok = true
517break
518end
519if ge ulong monons dl
520break
521end
522if lt sched_count 1 3 4
523j = pt_admit add mul s 100000 300 0 pt_req 1 0 0 0 60
524s = add s 1
525end
526pt_step c 60
527n = pt_review 60
528end
529pt_ok ok 61
530pt_ok ge sched_stat 6 1 62
531pt_ok ge sched_stat 9 1 63
532pt_drain c sched_count 1 4 5000 64
533pt_stats
534pt_ok eq get suse 0 0 65
535pt_down c 66
536end
537
538note Phase Q: admission tickets. Limit 2: p1 (400 ms) and p2 (900 ms) fill
539note it; X then Y are refused and hold tickets in that order. When p1 is
540note reviewed there is room for one: Y asking first is refused (75), X is
541note admitted (76); Y enters once more room returns (78). A ticket not
542note asked about for the lifetime (20 events) lapses, so a new caller is
543note admitted although the old holder never came back (80). The wait for
544note the lapse reviews whatever finishes, 140900 included when it outlasts
545note that job's 900 ms, so the last drain waits for the jobs still
546note outstanding, not a fixed two: a fixed two timed out (80) whenever the
547note loop had already reviewed 140900.
548fn pt_tickets to void
549c = pt_setup 2 2 8 pt_req 4 1024 1 8 70
550pt_ok eq sched_policy sched_stat 24 64 64 sched_stat 27 1000 0 70
551p1 = pt_admit 100400 0 0 70
552p2 = pt_admit 110900 0 0 70
553pt_ok eq sched_admitr 120050 0 0 0 neg long 2 71
554pt_ok eq sched_admitr 130050 0 0 0 neg long 2 72
555pt_ok eq sched_stat 30 2 73
556pt_drain c 1 3000 74
557pt_ok eq sched_admitr 130050 0 0 0 neg long 2 75
558pt_ok ge sched_admitr 120050 0 0 0 0 76
559pt_drain c 2 3000 77
560pt_ok ge sched_admitr 130050 0 0 0 0 78
561pt_ok eq sched_policy sched_stat 24 64 64 sched_stat 27 20 0 79
562f = pt_admit 140900 0 0 79
563pt_ok eq sched_admitr 150050 0 0 0 neg long 2 79
564e0 = sched_stat 2
565dl = add ulong monons 3000000000
566for t ulong 1000000
567if le sched_count 1 3 1
568if gt sched_stat 2 add e0 21
569break
570end
571end
572pt_ok lt ulong monons dl 79
573pt_step c 79
574n = pt_review 79
575end
576pt_ok ge sched_admitr 160050 0 0 0 0 80
577pt_ok ge sched_stat 11 1 80
578pt_drain c sched_count 1 4 3000 80
579pt_down c 80
580end
581
582note Step until sched_overdue reports a job, up to 2 s: its slot, or 64.
583fn pt_waitod c long code int to ulong
584t0 = ulong monons
585for t ulong 1000000
586o = sched_overdue
587if lt o 64
588ret o
589end
590if gt sub ulong monons t0 2000000000
591ret 64
592end
593pt_step c code
594end
595ret 64
596end
597
598note Phase L: lease expiry. h (2 of 2 CPU, 3 s, not safe to rerun) has a
599note 200 ms lease: its deadline is at least 200 ms after h was admitted, and
600note sched_overdue reports it once, at or after that deadline (83); the
601note creator kills its worker; h becomes UNKNOWN and its CPU is free.
602note h2 (2 CPU, 400 ms, safe to rerun, 100 ms lease) is killed the same
603note way: it is ready or running again with its admission age kept, and
604note completes. Then a new 2-CPU job runs.
605fn pt_lease to void
606c = pt_setup 3 8 8 pt_req 2 1024 1 8 81
607t0 = ulong monons
608h = pt_admit 173000 0 pt_req 2 0 0 0 81
609pt_ok eq sched_lease h 200000000 0 81
610pt_ok pt_until c h 3 3 2000 81 81
611due = get sjdue h
612pt_ok ge due add t0 200000000 83
613o = pt_waitod c 82
614pt_ok eq o h 82
615pt_ok ge ulong monons due 83
616pt_ok eq sched_overdue 64 84
617r = killpid int get swpid get sjw h 9
618pt_ok pt_until c h 6 6 2000 85 85
619pt_ok eq get suse 0 0 86
620pt_ok eq sched_settle h 0 87
621x = sched_admitr 180400 0 1 pt_req 2 0 0 0
622pt_ok ge x 0 140
623h2 = ulong x
624pt_ok eq sched_lease h2 100000000 0 140
625pt_ok pt_until c h2 3 3 2000 140 140
626ar = get sjarr h2
627pt_ok eq pt_waitod c 141 h2 141
628w = get sjw h2
629r = killpid int get swpid w 9
630dl = add ulong monons 2000000000
631for t ulong 1000000
632if eq get swpid w 0
633break
634end
635pt_ok lt ulong monons dl 142
636pt_step c 142
637end
638pt_ok eq get sjarr h2 ar 143
639s = get sjst h2
640pt_ok and ge s 2 le s 3 144
641pt_drain c 1 3000 145
642z = pt_admit 190050 0 pt_req 2 0 0 0 88
643pt_drain c 1 3000 88
644pt_down c 89
645end
646
647note Phase R: cancellation of a reserved job. Bypass budget 1: a (1 of 2
648note CPU) runs, b (2 CPU) waits, x (1 CPU) runs past it, so b is reserved.
649note Cancelling b frees it with no effect and clears the reservation.
650fn pt_rcancel to void
651c = pt_setup 2 8 8 pt_req 2 1024 1 8 90
652pt_ok eq sched_policy sched_stat 24 64 64 1 1000 0 90
653a = pt_admit 190600 0 pt_req 1 0 0 0 90
654pt_ok pt_until c a 3 3 2000 90 90
655b = pt_admit 200050 0 pt_req 2 0 0 0 90
656x = pt_admit 210050 0 pt_req 1 0 0 0 90
657pt_ok pt_until c x 3 4 400 90 91
658pt_ok eq sched_stat 29 add b 1 92
659pt_ok eq sched_cancel b 1 93
660pt_ok eq sched_stat 29 0 94
661pt_drain c 2 3000 95
662pt_ok eq get suse 0 0 96
663pt_down c 97
664end
665
666note Phase W: bounded candidate work. Window 4 slots, dispatch budget 2,
667note two workers, so an event may pick twice: 12 ready jobs fill slots
668note 0..11, beyond any one window. Each pick reads at most 5 slots (the
669note reserved probe and the window, exit 9), every window scan moves the
670note cursor on by 4 (15), and all 12 run. 101 means some never did.
671fn pt_window to void
672c = pt_setup 2 16 16 pt_req 4 1024 1 8 101
673pt_ok eq sched_policy sched_stat 24 4 2 sched_stat 27 1000 0 101
674for i ulong 12
675j = pt_admit add mul add i 1 10000 30 0 0 101
676end
677pt_drain c 12 5000 101
678pt_ok eq sched_stat 4 12 102
679pt_down c 103
680end
681
682note Phase T: ticket order with several openings. Limit 3 held by p1, p2
683note (400 ms) and p3, which waits on a topic nobody publishes; X, Y, Z are
684note refused in that order and hold tickets (104). p1 and p2 are reviewed,
685note so there are exactly two openings: Y asking first is refused (105), and
686note so is a new caller W, who takes a ticket behind Z (106); X enters
687note (107), then Y (108). p3 is cancelled and X and Y are reviewed, so there
688note are three openings: W asking first is refused, then Z and W enter (109).
689fn pt_torder to void
690c = pt_setup 3 3 8 pt_req 4 1024 1 8 104
691p = pt_admit 400400 0 0 104
692p = pt_admit 410400 0 0 104
693p3 = pt_admit 420050 4096 0 104
694pt_ok eq sched_admitr 430050 0 0 0 neg long 2 104
695pt_ok eq sched_admitr 440050 0 0 0 neg long 2 104
696pt_ok eq sched_admitr 450050 0 0 0 neg long 2 104
697pt_ok eq sched_stat 30 3 104
698pt_drain c 2 3000 104
699pt_ok eq sched_admitr 440050 0 0 0 neg long 2 105
700pt_ok eq sched_admitr 460050 0 0 0 neg long 2 106
701pt_ok eq sched_stat 30 4 106
702pt_ok ge sched_admitr 430050 0 0 0 0 107
703pt_ok ge sched_admitr 440050 0 0 0 0 108
704pt_ok eq sched_cancel p3 1 108
705pt_drain c 2 3000 108
706pt_ok eq sched_admitr 460050 0 0 0 neg long 2 109
707pt_ok ge sched_admitr 450050 0 0 0 0 109
708pt_ok ge sched_admitr 460050 0 0 0 0 109
709pt_drain c 2 3000 109
710pt_down c 109
711end
712
713note Phase X: the table, not the admission limit, is full. Admission limit
714note and review limit 64; 64 jobs finish and wait in review, so none is
715note admitted, waiting, ready or running. A new caller is refused and takes
716note a ticket (190, 191), as is a second (192). One review frees one slot:
717note the second holder is refused, the first enters (193, 194).
718fn pt_slots to void
719c = pt_setup 3 64 64 pt_req 4 1024 1 8 190
720for i ulong 64
721j = pt_admit add 500001 mul i 10000 0 0 190
722end
723dl = add ulong monons 5000000000
724for t ulong 1000000
725if eq sched_count 4 4 64
726break
727end
728pt_ok lt ulong monons dl 190
729pt_step c 190
730end
731pt_ok not sched_room 600050 191
732pt_ok eq sched_stat 30 1 191
733pt_ok eq sched_admitr 600050 0 0 0 neg long 2 192
734pt_ok eq sched_admitr 610050 0 0 0 neg long 2 192
735pt_ok eq sched_stat 30 2 192
736pt_ok eq sched_review 0 long add get sjid 0 1 193
737pt_ok eq sched_admitr 610050 0 0 0 neg long 2 193
738pt_ok ge sched_admitr 600050 0 0 0 0 194
739n = pt_review 194
740pt_ok ge sched_admitr 610050 0 0 0 0 194
741pt_drain c 2 3000 194
742pt_down c 194
743end
744
745note Phase Z: reserved progress needs review progress. Review limit 1, two
746note workers, 2 CPU, bypass budget 1. p finishes and waits in review,
747note unreviewed. a (1 CPU) and x (1 CPU) run past b (2 CPU), so b is
748note reserved (196). a and x finish; their workers keep the results, since
749note review is full, so b is ready at every step for 600 ms (197) and all
750note CPU is free at the end of that interval (198). Reviewing p lets a into
751note review, frees its worker, and b runs (199).
752fn pt_live to void
753c = pt_setup 2 8 1 pt_req 2 1024 1 8 195
754pt_ok eq sched_policy sched_stat 24 64 64 1 1000 0 195
755p = pt_admit 470050 0 pt_req 1 0 0 0 195
756pt_ok pt_until c p 4 4 2000 195 195
757k = sched_pause c true
758a = pt_admit 480050 0 pt_req 1 0 0 0 195
759b = pt_admit 490050 0 pt_req 2 0 0 0 195
760x = pt_admit 510050 0 pt_req 1 0 0 0 195
761pt_resume c
762pt_ok eq sched_stat 29 add b 1 196
763dl = add ulong monons 600000000
764for t ulong 1000000
765if ge ulong monons dl
766break
767end
768pt_step c 197
769pt_ok eq get sjst b 2 197
770end
771pt_ok eq get suse 0 0 198
772pt_ok eq sched_review p long add get sjid p 1 199
773pt_ok pt_until c b 3 4 2000 199 199
774pt_drain c 3 3000 199
775pt_down c 199
776end
777
778note Phase M: lease bounds (2^50 ns, about 13 days). Waiting job w refuses
779note 2^50 + 1 and 2^64 - 1 (-7) with its lease unchanged (200, 201) and
780note accepts 2^50 (202). Job r, leased 2^50 before it is assigned, runs with
781note a deadline ahead of the clock and nothing overdue (203); running, it
782note refuses both too large values with lease and deadline unchanged (204,
783note 205) and accepts a renewal of 2^49 measured from now: the new deadline
784note lies between clock + 2^49 read just before and just after the call
785note (206), and nothing is overdue; it then completes (207).
786fn pt_lbound to void
787c = pt_setup 1 8 8 pt_req 2 1024 1 8 200
788mx = ulong 1125899906842624
789w = pt_admit 220050 1 0 200
790pt_ok eq sched_lease w add mx 1 neg long 7 200
791pt_ok eq get sjlse w 0 200
792pt_ok eq sched_lease w sub ulong 0 1 neg long 7 201
793pt_ok eq get sjlse w 0 201
794pt_ok eq sched_lease w mx 0 202
795pt_ok eq get sjlse w mx 202
796r = pt_admit 230600 0 pt_req 1 0 0 0 203
797pt_ok eq sched_lease r mx 0 203
798pt_ok pt_until c r 3 3 2000 203 203
799d = get sjdue r
800pt_ok gt d ulong monons 203
801pt_ok eq sched_overdue 64 203
802pt_ok eq sched_lease r sub ulong 0 1 neg long 7 204
803pt_ok and eq get sjdue r d eq get sjlse r mx 204
804pt_ok eq sched_lease r add mx 1 neg long 7 205
805pt_ok and eq get sjdue r d eq get sjlse r mx 205
806w = ulong monons
807pt_ok eq sched_lease r div mx 2 0 206
808t2 = ulong monons
809pt_ok ge get sjdue r add w div mx 2 206
810pt_ok le get sjdue r add t2 div mx 2 206
811pt_ok eq sched_overdue 64 206
812pt_drain c 1 3000 207
813pt_down c 207
814end
815
816note Phase N: every ask renews a ticket, a successful one too. Admission
817note limit 1, ticket lifetime 2. o waits on a topic nobody publishes and
818note fills the limit; X is refused at event e and holds a ticket. o is
819note cancelled; at event e + 1 X asks and is told yes, which renews its
820note ticket (210). At e + 3 the ticket still holds (asked at e + 1, lifetime
821note 2), so newcomer Y is refused (211); at e + 4 it lapses, exactly one
822note lapse is counted and Y, now first, is admitted (212).
823fn pt_renew to void
824c = pt_setup 1 1 8 pt_req 2 1024 1 8 210
825pt_ok eq sched_policy sched_stat 24 64 64 sched_stat 27 2 0 210
826o = pt_admit 240050 1 0 210
827pt_ok eq sched_admitr 250050 0 0 0 neg long 2 210
828pt_ok eq sched_cancel o 1 210
829k = sched_dispatch c
830pt_ok sched_room 250050 210
831k = sched_dispatch c
832k = sched_dispatch c
833pt_ok eq sched_admitr 260050 0 0 0 neg long 2 211
834l0 = sched_stat 11
835k = sched_dispatch c
836pt_ok ge sched_admitr 260050 0 0 0 0 212
837pt_ok eq sched_stat 11 add l0 1 212
838pt_drain c 1 3000 212
839pt_down c 212
840end
841
842note Phase U: the dispatch budget binds. Four idle workers, dispatch budget
843note 2, six ready 1-CPU jobs and 4 CPU: one dispatch assigns exactly 2
844note (220); all six then complete (221).
845fn pt_budget to void
846c = pt_setup 4 16 16 pt_req 4 1024 1 8 220
847pt_ok eq sched_policy sched_stat 24 64 2 sched_stat 27 1000 0 220
848for i ulong 6
849j = pt_admit add 270100 mul i 10000 0 pt_req 1 0 0 0 220
850end
851a0 = sched_stat 4
852k = sched_dispatch c
853pt_ok and eq k 2 eq sub sched_stat 4 a0 2 220
854pt_drain c 6 5000 221
855pt_down c 221
856end
857
858fn pt_mode to void
859a = new uchar 16 0
860if ne argcnt 2
861ret
862end
863n = argread 1 a 0 16
864if eq n 4
865if eq get a 0 102
866put ptm 0 1
867end
868if eq get a 0 103
869put ptm 0 3
870end
871end
872if eq n 9
873put ptm 0 2
874end
875end
876
877note Step, then review every job in review in slot order, appending its id
878note to the trace and publishing the topics it declared (as the workflow
879note does after accepting a result).
880fn pt_gstep c long buf edit uchar 4096 code int to void
881pt_step c code
882for j ulong 64
883if eq get sjst j 4
884p = get sjpro j
885n = get ptn 0
886if lt n 16
887put ptt n get sjid j
888end
889put ptn 0 add n 1
890pt_ok eq sched_review j long add get sjid j 1 code
891if ne p 0
892pt_snap
893pt_ok gt sched_publish c p buf 16 0 code
894pt_check
895end
896end
897end
898end
899
900fn pt_gadmit id ulong deps ulong pro ulong code int to ulong
901j = pt_admit id deps pt_req 1 0 0 0 code
902if ne pro 0
903pt_ok eq sched_goal j pro 50 10 0 code
904end
905ret j
906end
907
908note One run of the goal workload, one worker, policy 2, bypass budget 4,
909note admitted while paused: x (no value), z (unblocks d: value 1), a
910note (unblocks b, which unblocks c: value 2), f (unblocks g1..g3: value 3).
911note A decision is made when the worker frees, before the finished job's
912note topics are published. Order: f a z b x d c g1 g2 g3. f and a first
913note (useful work); x, bypassed in 4 events, is reserved and runs 5th.
914fn pt_grun code int to void
915buf = new uchar 4096 0
916c = pt_setup 1 16 16 pt_req 1 1024 1 8 code
917pt_ok eq sched_policy 2 64 64 4 1000 0 code
918k = sched_pause c true
919put ptn 0 0
920j = pt_gadmit 220050 0 0 code
921j = pt_gadmit 230050 0 128 code
922j = pt_gadmit 240050 128 0 code
923j = pt_gadmit 250050 0 32 code
924j = pt_gadmit 260050 32 64 code
925j = pt_gadmit 270050 64 0 code
926j = pt_gadmit 280050 0 256 code
927for i ulong 3
928j = pt_gadmit add 290050 mul i 10000 256 0 code
929end
930pt_resume c
931dl = add ulong monons 5000000000
932for t ulong 1000000
933if ge get ptn 0 10
934break
935end
936pt_ok lt ulong monons dl code
937pt_gstep c buf code
938end
939pt_down c code
940end
941
942note Phase G: goal-aware ranking. The goal workload runs twice; both traces
943note must equal the expected order (151 first run, 152 second): repeated
944note identical inputs, identical decisions.
945fn pt_goal to void
946ex = new ulong 10 0
947put ex 0 280050
948put ex 1 250050
949put ex 2 230050
950put ex 3 260050
951put ex 4 220050
952put ex 5 240050
953put ex 6 270050
954put ex 7 290050
955put ex 8 300050
956put ex 9 310050
957for r ulong 2
958code = int add 151 r
959pt_grun 150
960pt_ok eq get ptn 0 10 code
961for i ulong 10
962if ne get ptt i get ex i
963pt_trace
964exit code
965end
966end
967end
968end
969
970fn pt_trace to void
971r = write 1 ptr 0 len ptr
972for i ulong get ptn 0 bound 16
973pt_num get ptt i
974r = write 1 psp 0 1
975end
976r = write 1 pnl 0 1
977end
978
979note Phase H: rescoring. Policy 2, paused: one ready job r and two jobs
980note waiting on topic 512, then r declares topic 512: four graph changes,
981note no rescoring (160). The first pick rescores once for all four (161).
982note r completing and being reviewed with nothing published changes no
983note value: no rescoring (162). Publishing 512 readies both waiting jobs:
984note two changes, one more rescoring at the next pick (163). The work of
985note every rescoring is bounded (checked at each step, exit 8). Cancelling
986note a waiting job is one more change (165).
987fn pt_rescores to void
988buf = new uchar 4096 0
989c = pt_setup 1 8 8 pt_req 4 1024 1 8 160
990pt_ok eq sched_policy 2 64 64 4 1000 0 160
991k = sched_pause c true
992r = pt_admit 320050 0 pt_req 1 0 0 0 160
993w1 = pt_admit 330050 512 pt_req 1 0 0 0 160
994w2 = pt_admit 340050 512 pt_req 1 0 0 0 160
995pt_ok eq sched_goal r 512 50 10 0 160
996pt_ok eq sched_stat 34 4 160
997pt_ok eq sched_stat 32 0 160
998pt_resume c
999pt_ok eq sched_stat 32 1 161
1000pt_ok eq get sjval r 2 161
1001pt_drain c 1 2000 162
1002pt_ok eq sched_stat 32 1 162
1003pt_ok eq sched_stat 34 4 162
1004pt_snap
1005pt_ok gt sched_publish c 512 buf 16 0 163
1006pt_check
1007pt_ok eq sched_stat 34 6 163
1008pt_ok eq sched_stat 32 2 163
1009pt_drain c 2 2000 164
1010pt_ok eq sched_stat 32 2 165
1011w3 = pt_admit 345050 4096 pt_req 1 0 0 0 165
1012b0 = sched_stat 34
1013pt_ok eq sched_cancel w3 1 165
1014pt_ok eq sched_stat 34 add b0 1 165
1015pt_down c 166
1016end
1017
1018note Phase K: the policy-2 key on two free slots, a and b. Larger unblock
1019note value first, even when b is older and cheaper (180); equal values:
1020note smaller estimate first, even when b is older (181); equal values and
1021note estimates: older admission first (182); outside policy 2 only the
1022note admission age counts (183).
1023fn pt_key to void
1024a = ulong 60
1025b = ulong 61
1026put sjval a 2
1027put sjval b 1
1028put sjest a 90
1029put sjest b 10
1030put sjarr a 9
1031put sjarr b 8
1032pt_ok sp_better true a b 180
1033pt_ok not sp_better true b a 180
1034put sjval b 2
1035put sjest a 10
1036put sjest b 90
1037pt_ok sp_better true a b 181
1038pt_ok not sp_better true b a 181
1039put sjest b 10
1040pt_ok sp_better true b a 182
1041pt_ok not sp_better true a b 182
1042put sjval a 5
1043put sjest b 1
1044pt_ok sp_better false b a 183
1045pt_ok not sp_better false a b 183
1046for i ulong 2
1047put sjval add a i 0
1048put sjest add a i 0
1049put sjarr add a i 0
1050end
1051end
1052
1053note Phase P: proposals. Policy 2, paused. p1 (value 0) and p2 (value 1)
1054note are ready. A proposal naming an older graph version is refused (170)
1055note and counted (171); one naming an id with no ready job is refused
1056note (172); p1 at the current version is accepted (173) and used over the
1057note higher ranked p2 (174). A proposal made stale by a later change is
1058note rejected when next used and counted: p3 runs by rank, after p2 (175,
1059note 176). Outside policy 2: -7 (177).
1060fn pt_proposals to void
1061c = pt_setup 1 8 8 pt_req 4 1024 1 8 170
1062pt_ok eq sched_incarnate 1 0 170
1063pt_ok eq sched_policy 2 64 64 4 1000 0 170
1064k = sched_pause c true
1065p1 = pt_admit 350050 0 pt_req 1 0 0 0 170
1066p2 = pt_admit 360050 0 pt_req 1 0 0 0 170
1067q = pt_admit 370050 1024 pt_req 1 0 0 0 170
1068pt_ok eq sched_goal p2 1024 50 10 0 170
1069v = sched_version
1070p3 = pt_admit 380050 0 pt_req 1 0 0 0 170
1071pt_ok eq sched_propose 350050 v neg long 9 170
1072pt_ok eq sched_stat 36 1 171
1073v = sched_version
1074pt_ok eq sched_propose 999999 v neg long 3 172
1075pt_ok eq sched_propose 350050 v 0 173
1076pt_resume c
1077pt_ok eq get sjst p1 3 174
1078pt_ok eq sched_stat 39 1 174
1079k = sched_pause c true
1080v = sched_version
1081pt_ok eq sched_propose 380050 v 0 175
1082p4 = pt_admit 390050 2048 pt_req 1 0 0 0 175
1083pt_ok eq sched_goal p3 0 10 1 0 175
1084pt_resume c
1085pt_ok pt_until c p2 3 4 2000 175 175
1086pt_ok eq get sjst p3 2 176
1087pt_ok eq sched_stat 39 1 176
1088pt_ok eq sched_stat 36 2 176
1089pt_ok eq sched_cancel p4 1 176
1090pt_ok eq sched_cancel q 1 176
1091pt_drain c 3 3000 176
1092pt_ok eq sched_policy 1 64 64 4 1000 0 177
1093pt_ok eq sched_propose 350050 sched_version neg long 7 177
1094pt_down c 178
1095end
1096
1097note Phase I: a proposal from an earlier scheduler. Scheduler 1
1098note (incarnation 1) admits a into slot 0 and hands out the version;
1099note scheduler 2 (incarnation 2) admits b into slot 0 with as many bumps.
1100note There the old version is stale (184); a's id names no job even at the
1101note current version, b's is accepted, and incarnation 0 is refused (185).
1102fn pt_incarn to void
1103c = pt_setup 1 8 8 pt_req 4 1024 1 8 184
1104pt_ok eq sched_incarnate 1 0 184
1105pt_ok eq sched_policy 2 64 64 4 1000 0 184
1106k = sched_pause c true
1107a = pt_admit 670050 0 pt_req 1 0 0 0 184
1108pt_ok eq a 0 184
1109v1 = sched_version
1110pt_ok eq sched_cancel a 1 184
1111pt_down c 184
1112c = pt_setup 1 8 8 pt_req 4 1024 1 8 184
1113pt_ok eq sched_incarnate 2 0 184
1114pt_ok eq sched_policy 2 64 64 4 1000 0 184
1115k = sched_pause c true
1116b = pt_admit 680050 0 pt_req 1 0 0 0 184
1117pt_ok eq b 0 184
1118pt_ok eq sched_propose 670050 v1 neg long 9 184
1119pt_ok eq sched_propose 670050 sched_version neg long 3 185
1120pt_ok eq sched_propose 680050 sched_version 0 185
1121pt_ok eq sched_incarnate 0 neg long 7 185
1122pt_ok eq sched_cancel b 1 185
1123pt_down c 185
1124end
1125
1126note Phase R2: a proposal beside a reservation. Policy 2, bypass budget 1,
1127note two workers, 5 CPU. h (2 CPU, 5 s) runs; then B and B2 (4 CPU each)
1128note and s1 (1 CPU, 1.5 s) are admitted: s1 runs, B and B2 are bypassed and
1129note B, the older, is reserved. x (2 CPU) is refused beside it and counted
1130note (186). Cancelling B clears the reservation and x is accepted (187).
1131note An event with no idle worker reserves B2 and leaves the proposal
1132note pending (188). Once s1 is done, the next pick finds x no longer fits
1133note beside B2: the proposal is dropped and counted stale, and x does not
1134note run (189). Once h is done B2 fits; y (1 CPU) is accepted beside it,
1135note and at the next event B2 runs first, then y is used; x (2 CPU, 0
1136note left) stays ready and, bypassed by y, is now the reservation (179).
1137fn pt_propres to void
1138c = pt_setup 2 8 8 pt_req 5 1024 2 8 186
1139pt_ok eq sched_incarnate 1 0 186
1140pt_ok eq sched_policy 2 64 64 1 1000 0 186
1141k = sched_pause c true
1142h = pt_admit 625000 0 pt_req 2 0 0 0 186
1143pt_resume c
1144k = sched_pause c true
1145pt_ok eq get sjst h 3 186
1146b = pt_admit 630050 0 pt_req 4 0 0 0 186
1147b2 = pt_admit 640050 0 pt_req 4 0 0 0 186
1148s1 = pt_admit 651500 0 pt_req 1 0 0 0 186
1149pt_resume c
1150k = sched_pause c true
1151pt_ok eq get sjst s1 3 186
1152pt_ok eq sched_stat 29 add b 1 186
1153x = pt_admit 660050 0 pt_req 2 0 0 0 186
1154r0 = sched_stat 37
1155pt_ok eq sched_propose 660050 sched_version neg long 8 186
1156pt_ok eq sched_stat 37 add r0 1 186
1157pt_ok eq sched_cancel b 1 187
1158pt_ok eq sched_stat 29 0 187
1159pt_ok eq sched_propose 660050 sched_version 0 187
1160pt_resume c
1161k = sched_pause c true
1162pt_ok eq sched_stat 29 add b2 1 188
1163pt_ok gt get scgv 2 0 188
1164pt_ok pt_until c s1 4 4 3000 188 188
1165s0 = sched_stat 36
1166pt_resume c
1167k = sched_pause c true
1168pt_ok eq sched_stat 36 add s0 1 189
1169pt_ok eq get sjst x 2 189
1170pt_ok eq get scgv 2 0 189
1171y = pt_admit 690050 0 pt_req 1 0 0 0 179
1172pt_ok pt_until c h 4 4 6000 179 179
1173pt_ok eq sched_propose 690050 sched_version 0 179
1174s0 = sched_stat 39
1175pt_resume c
1176k = sched_pause c true
1177pt_ok eq get sjst b2 3 179
1178pt_ok eq get sjst y 3 179
1179pt_ok eq sched_stat 39 add s0 1 179
1180pt_ok eq sched_stat 29 add x 1 179
1181pt_ok eq get sjst x 2 179
1182pt_ok eq sched_cancel x 1 179
1183pt_drain c 4 8000 179
1184pt_down c 189
1185end
1186
1187fn pt_stats to void
1188r = write 1 pst 0 len pst
1189pt_num sched_stat 2
1190r = write 1 pex 0 len pex
1191pt_num sched_stat 3
1192r = write 1 pas 0 len pas
1193pt_num sched_stat 4
1194r = write 1 phol 0 len phol
1195pt_num sched_stat 8
1196r = write 1 pbyp 0 len pbyp
1197pt_num sched_stat 5
1198r = write 1 pres 0 len pres
1199pt_num sched_stat 6
1200r = write 1 pnl 0 1
1201end
1202
1203note Phase X: proposal guards. Without an incarnation a proposal is refused
1204note (120); a second incarnation is refused (121); after the first one a
1205note proposal is accepted and used (122). The version is then set to the
1206note last revision of incarnation 5 (2^40 - 1 bumps): a proposal made there
1207note is accepted, and the next bump exhausts the version instead of
1208note carrying it into incarnation 6's range (123); proposals are refused
1209note (124), the pending one is dropped at use (125) and every pick rescores
1210note (126). In a new scheduler, two ready jobs share an id: a proposal
1211note naming it is refused (127).
1212fn pt_incx to void
1213c = pt_setup 1 8 8 pt_req 4 1024 1 8 120
1214pt_ok eq sched_policy 2 64 64 4 1000 0 120
1215k = sched_pause c true
1216a = pt_admit 710050 0 pt_req 1 0 0 0 120
1217pt_ok eq sched_propose 710050 sched_version neg long 6 120
1218pt_ok eq sched_stat 41 0 120
1219pt_ok eq sched_incarnate 5 0 121
1220pt_ok eq sched_incarnate 6 neg long 7 121
1221pt_ok eq sched_propose 710050 sched_version 0 122
1222pt_ok eq sp_proposal 0 a 122
1223put scgv 0 add shl ulong 5 40 1099511627775
1224v = sched_version
1225pt_ok eq sched_propose 710050 v 0 123
1226pt_ok eq sched_goal a 0 10 1 0 123
1227pt_ok eq sched_version v 123
1228pt_ok eq shr sched_version 40 5 123
1229pt_ok eq sched_stat 41 2 123
1230pt_ok eq sched_propose 710050 v neg long 6 124
1231pt_ok eq sp_proposal 0 64 125
1232r0 = sched_stat 32
1233sp_rescore
1234sp_rescore
1235pt_ok eq sched_stat 32 add r0 2 126
1236pt_ok eq sched_cancel a 1 126
1237pt_down c 126
1238c = pt_setup 1 8 8 pt_req 4 1024 1 8 127
1239pt_ok eq sched_incarnate 7 0 127
1240pt_ok eq sched_policy 2 64 64 4 1000 0 127
1241k = sched_pause c true
1242b1 = pt_admit 720050 0 pt_req 1 0 0 0 127
1243b2 = pt_admit 720050 0 pt_req 1 0 0 0 127
1244pt_ok ne b1 b2 127
1245pt_ok eq sched_propose 720050 sched_version neg long 3 127
1246pt_ok eq sched_cancel b1 1 127
1247pt_ok eq sched_cancel b2 1 127
1248pt_down c 127
1249end
1250
1251note Phase L: a late first incarnation must not mark stale values current.
1252note Paused, one worker, policy 2: an older unrelated job u, a younger
1253note producer p declaring topic 64 and a job d waiting on it are admitted
1254note and declared, then the scheduler incarnates. At resume the one pick
1255note rescores and takes p (value 1); with the values left unscored they all
1256note read 0 and u (older, no estimate) would run instead (128).
1257fn pt_incl to void
1258c = pt_setup 1 8 8 pt_req 4 1024 1 8 128
1259pt_ok eq sched_policy 2 64 64 4 1000 0 128
1260k = sched_pause c true
1261u = pt_admit 730300 0 pt_req 1 0 0 0 128
1262p = pt_admit 740300 0 pt_req 1 0 0 0 128
1263d = pt_admit 750300 64 pt_req 1 0 0 0 128
1264pt_ok eq sched_goal p 64 300 0 0 128
1265pt_ok eq sched_incarnate 8 0 128
1266pt_resume c
1267pt_ok eq get sjst p 3 128
1268pt_ok eq get sjst u 2 128
1269pt_ok eq sched_cancel u 1 128
1270pt_ok eq sched_cancel d 1 128
1271pt_drain c 1 3000 128
1272pt_down c 128
1273end
1274
1275note The regression phases A and B return their verdict, so both run and
1276note print their witness; the first failing one is the exit status.
1277fn main to int
1278pt_mode
1279pt_impossible
1280pt_churn
1281pt_release
1282pt_order
1283ra = pt_blocked
1284rb = pt_exclude
1285if ne ra 0
1286ret ra
1287end
1288if ne rb 0
1289ret rb
1290end
1291pt_starve
1292pt_tickets
1293pt_lease
1294pt_rcancel
1295pt_window
1296pt_torder
1297pt_slots
1298pt_live
1299pt_goal
1300pt_rescores
1301pt_proposals
1302pt_incarn
1303pt_propres
1304pt_incx
1305pt_incl
1306pt_key
1307pt_lbound
1308pt_renew
1309pt_budget
1310if ne write 1 pok 0 len pok long len pok
1311ret 100
1312end
1313ret 0
1314end