"""Stress the production recent-first prebuild queue: changing concurrency must not omit or repeat any job.""" from pathlib import Path import subprocess import sys root = Path(__file__).resolve().parents[1] source = (root / 'runtime/vk_pipeline.c').read_text() start = source.index('static size_t lb_next(int worker)') brace = source.index('{', start) depth, end = 1, brace + 1 while depth: depth += (source[end] == '{') - (source[end] == '}') end += 1 harness = r''' #include #include #include #include static struct { volatile int64_t next; volatile int32_t stop; size_t n, n_keep; int idle, tail_one, bg_threads; } LB; static int bf_wait_now, bg_threads = 8; // bf_waiting(): the start waits for the whole warm static int lb_idle(void) { return LB.idle && !bf_wait_now; } static volatile LONG seen[2000]; static HANDLE start_event; ''' harness += source[start:end] harness += r''' static DWORD WINAPI worker(void *arg) { int id=(int)(intptr_t)arg; assert(WaitForSingleObject(start_event,2000)==WAIT_OBJECT_0); for (;;) { size_t i=lb_next(id); if (i>=LB.n) break; assert(InterlockedIncrement(&seen[i])==1); if (LB.idle && !bf_wait_now && LB.tail_one && i>=LB.n_keep) assert(id==0); if (LB.idle && !bf_wait_now) assert(id 1 else 'C:/msys64/ucrt64/bin/clang.exe' exe = out / 'check.exe' subprocess.run([cc, '-std=gnu11', '-O2', '-Wall', '-Wextra', '-Werror', str(c), '-o', str(exe)], check=True) subprocess.run([str(exe)], check=True, timeout=15)