From e934e755f14648fff6ebac07e9cf9e5b37cb3fe4 Mon Sep 17 00:00:00 2001 From: Pjotr Date: Sun, 8 Nov 2026 16:23:03 +0000 Subject: api: describe case attributes, and gate large computations only Two things that came out of reading a real response rather than a test. **Say what a case attribute means.** `GET /groups/{group}/case-attributes` returned names and values, and the per-trait attribute endpoint returned values, so a caller had to guess that `SeqCvge` is a sequencing depth. MariaDB has had the answer all along in `CaseAttribute.Description`: SeqCvge Depth of DNA sequencing for 1 male of each strain in 2016 Status Live= Available at JAX, Cryo=Cryopreserved only, Extinct Epoch BXD family subgroups. Each number with common parents. ... Sex F= female, M= male Both endpoints now carry it -- a `descriptions` map on the group listing, a `description` field on the per-trait one -- and the covariate notes quote it, so `/compute/gemma` answers "Covariate SeqCvge (Depth of DNA sequencing for 1 male of each strain in 2016): categorical ..." instead of leaving the name to be interpreted. It matters most for covariates: `SeqCvge` is a property of the *genotype* data, its values include compound ones (`40+31L`, two sequencing runs), and the server codes those as 20-odd levels rather than as a depth -- a covariate fitted for the wrong reason, which the description is the first hint against. **Gate large computations, not every computation.** The gate was applied to every job, so a 93-strain test request could be refused because somebody else's 6 000-individual run held the slot -- which is how the test suite started serialising itself behind a mutex, a workaround for the wrong problem. What the gate is for is *large* work: a BXD panel of ~200 finishes in seconds and two at once cost nothing, while UM-HET3's 6 382 write 207 MB of kinship per chromosome. It now starts at `LARGE_PANEL` (1 000 individuals): below that no slot is taken, nothing waits and nothing is refused; above it the old policy holds unchanged (1 slot for gemma, 1 for ravanan, `RQTL_MAX_CONCURRENT` for rqtl, one large job per caller, 409 naming the run in the way). The size is not known when the request arrives -- the panel is resolved server-side -- so the decorator now makes a *light* claim and the handler promotes it (`__gn4_claim.claim_slot_or_busy(individuals, rid)`) at the point where it knows, then hands it to `Gate::run` around the call that computes, so the slot still outlives a client disconnect. A light claim registers nothing and its drop removes nothing: only a held claim may touch the claimant map. * src/compute_gate.rs: `LARGE_PANEL`/`is_large`, `Gate::claim_light`, `Claim::claim_slot_or_busy`/`is_held`, `busy_error` (the 409 policy, moved out of `claim_or_busy`), and `Gate::run` unchanged in spirit. * gnauth-macros: binds the light claim; the body keeps one gate call. * src/routes/{gemma,rqtl}.rs: promotion after the panel/sample count is known, and the compute call wrapped in `run`; error mapping moved inside the job so the future returns `ApiError`. * src/rqtl.rs: `Sample` is `Clone` (the job owns its copy). * tests: the gemma suite loses its lock entirely (the fixtures and BXD.4 are under the threshold); rqtl keeps its lock only for the machine's sake -- concurrent `Rscript` scans would compete for cores and scratch, not for a slot. Four new gate tests pin the threshold, that a small job never takes the slot, that one caller cannot hold two large jobs, and that another caller waits rather than fails. * README.md, docs/www/ai-instruction.md, docs/www/operator-checklist.md: what the threshold is and why it is 1 000. Measured on :3001 after the change: two concurrent small-panel GEMMA requests from one token both answer 200 (one was 409 before), while two 6 382-individual requests answer 502/409 -- the second gated with the usual `compute_busy` naming the first. 277 tests pass; the same four as before do not. --- docs/www/ai-instruction.md | 24 +++++++++++++++--------- docs/www/operator-checklist.md | 21 +++++++++++++++------ 2 files changed, 30 insertions(+), 15 deletions(-) (limited to 'docs') diff --git a/docs/www/ai-instruction.md b/docs/www/ai-instruction.md index 06e6595..81f2ae8 100644 --- a/docs/www/ai-instruction.md +++ b/docs/www/ai-instruction.md @@ -493,15 +493,21 @@ that rather than assembling your own. Until then, judge a GEMMA peak against the smallest `p_lrt` it reached, not against a genome-wide threshold of its own. -**A few jobs at a time, one per caller.** Each compute endpoint has a -fixed number of slots — **1** for `/compute/gemma`, **1** for -`/compute/gemma/ravanan`, **8** for `/compute/rqtl` — and one job per -caller within them. A second submission -from *your* token while your job is still running or queued is refused at -once with `409 compute_busy`, naming the run and linking its status -endpoint; a submission that finds every slot taken waits for one to come -free and then runs. So a 409 here is not a retry-able failure: poll the -status endpoint it names, and only then submit the next job. (If you want +**Large jobs are gated, small ones are not.** The gate is there to stop +*large* computations piling up on the server, so it begins at **1 000 +individuals**: a request over a smaller panel — BXD's ~200, an older +93-strain version, any of the fixtures — takes no slot, runs alongside +whatever else is running, and is never refused. That is most exploratory +work, and it costs nothing to fire a few of those off. + +Above the threshold, each endpoint has a fixed number of slots — **1** for +`/compute/gemma`, **1** for `/compute/gemma/ravanan`, **8** for +`/compute/rqtl` — and one large job per caller within them. A second large +submission from *your* token while your job is still running or queued is +refused at once with `409 compute_busy`, naming the run and linking its +status endpoint; a large submission that finds every slot taken waits for +one to come free and then runs. So a 409 here is not a retry-able failure: +poll the status endpoint it names, and only then submit again. (If you want more parallelism, that is more *tokens*, not more requests from one.) Results are **cached** by input, so running the same request twice costs diff --git a/docs/www/operator-checklist.md b/docs/www/operator-checklist.md index 47319eb..4f245d4 100644 --- a/docs/www/operator-checklist.md +++ b/docs/www/operator-checklist.md @@ -207,12 +207,21 @@ up-but-useless service is visible without calling a data endpoint. ## Compute concurrency -`POST /compute/gemma` takes one job at a time and `POST /compute/rqtl` -`RQTL_MAX_CONCURRENT` (default 8), and `/compute/gemma/ravanan` one at a -time, each one job per caller. All three are in-process gates -(`src/compute_gate.rs`), so they are per server process and reset on -restart -- a job's child process, however, outlives the server. Waits are -bounded only by nginx's `proxy_read_timeout`. +The gates exist to stop **large** computations piling up, so they only +apply above `compute_gate::LARGE_PANEL` (1 000 individuals); a smaller +panel takes no slot, which is why the in-process test suite no longer +serialises itself. Above it, `POST /compute/gemma` takes one job at a time, +`POST /compute/rqtl` `RQTL_MAX_CONCURRENT` (default 8) and +`/compute/gemma/ravanan` one at a time, each one large job per caller. All +three are in-process gates (`src/compute_gate.rs`), so they are per server +process and reset on restart -- a job's child process, however, outlives +the server. Waits are bounded only by nginx's `proxy_read_timeout`. + +The slot count is fixed when a gate is first built (its first large +request), so raising `RQTL_MAX_CONCURRENT` takes a restart, not a reload. +Lowering the threshold is the same: `LARGE_PANEL` is a constant, and the +reason it is 1 000 is in its doc comment (measured K-matrix sizes and run +times). ## Plotting -- cgit 1.4.1