pgw#1137 (§4.30, pgw#1127 item 6): a mint on the USER'S machine is polite — declared, not toggled - #655
Merged
Merged
Conversation
…lite — declared, not toggled pgw#1127 S1 pointed `cozy serve` at the real mint chain, so cozy-local now compiles on a desktop using clamps that were all written for a serving pod with a co-resident TENANT rather than a co-resident HUMAN. §6 of that issue recorded the evidence: zero `os.nice` calls anywhere in src/. THE FACT IS DECLARED, NOT SNIFFED. `compile_posture.CompilePosture` carries it, `local_serve` is the one site that says USER_MACHINE, and it rides `MintRequest` as a typed field beside `vram_cap_bytes`. Three near-miss proxies are rejected in the module docstring and fenced by a test: `trust_class()` and `publisher is None` are facts about the SINK (a rented community-cloud pod matches both and has nobody on it), and `worker_goals` says what a pod was BOUGHT to do. Not an env either — §1.17, an env may carry a VALUE, not a DECISION. CPU: the mint child nices ITSELF to 19. Not a `preexec_fn` — that forces fork() over posix_spawn() for a process with live gRPC threads and pthread_atfork handlers, which `arm_parent_death_signal`'s docstring already writes down. It also covers strictly more: since pgw#1080 every production mint is weight-free and therefore SERIAL in that very process, so nicing the pool's spawns would nice a path that does not run today. Nice is inherited, so one call covers the serial compile, the entry children when pgw#1111 restores them, inductor's workers and every cc1plus. `entry_workers` also halves the core budget and the ceiling (8 -> 4): priority preserves interactivity, but does nothing for K concurrent cc1plus, K inductor caches and K working sets in the page cache. MEMORY: the host reserve doubles to 8 GiB. MemAvailable counts the user's page cache as free, and a mint that OOMs a desktop is worse than a slow one. HONESTY: the compile now says what it is, that it happens once, where the cell goes, what it is taking, and that Ctrl-C is safe — then a throttled progress line every 10 s. Before this the only signals were an activity addressed to a hub cozy-local does not have and a logger.info inside a subprocess. INTERRUPTIBILITY: the child arms PR_SET_PDEATHSIG on a user machine. It is spawned start_new_session=True, so a closed terminal left a full-speed compile tree running with nobody to reap it. `aot_resume`'s bank already sits outside the per-attempt workdir, so nothing finished is lost. THE POD IS UNTOUCHED. FLEET is the struct default everywhere, and the width is proven arithmetically identical against an independent re-implementation of the pre-issue formula over six pod shapes. Every politeness claim is individually mutation-proven RED; the whole file is a collection error on origin/master. Rejected with reasons: an interactivity probe (cross-platform mess, and wrong for the developer running a build in a terminal — nice already IS the yield), ionice (no stdlib wrapper, a no-op on the schedulers desktops ship), and a third posture for community cloud.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes pgw#1127 §7 item 6 (filed, unowned) and discharges DESIGN-RULINGS §4.30's "be nice, especially on cozy-local — never saturate the user's only machine."
What cozy-local does today (before this PR)
cli/run.py:872→local_serve.enable_compiled→mint_delegate.build_cell→mint_process.run→mint_child. Sinceb29a5e95that is the REAL mint chain on a desktop, and:os.niceappears nowhere insrc/(pgw#1127 §6).SERVING_HEADROOM_CPUS = 2(aot_compile_pool.py:132) is sized for "an asyncio beat and an eager forward", i.e. a pod's tenant. On a 32-core desktop that leavescpu_workers = 15.MAX_ENTRY_WORKERS = 8(:171) bounds inductor-cache write amplification and concurrentcc1plus"on a box whose disk the serving process also uses" — here that disk is the user's.ENTRY_RSS_RESERVE_BYTES = 4 GiB(:196) protects a tenant request from the OOM killer;MemAvailablecounts the user's page cache as free.compile_threadsis NOT torch's 32 here —aot_mint.MINT_COMPILE_THREADS = 4is set as a default ataot_mint.py:805. Genuinely chosen, and left alone.aot_mint.py:2187-2204forcesparallel=Falsefor a weight-free mint, and since pgw#1080 every production mint is weight-free. So the compile runs IN the mint child — which is why nicing the pool's spawns (the parked1111-mint-parallelism-restoreapproach) would nice a path that does not currently run.mint_process.py:750spawnsstart_new_session=True, andmint_childarmed noPR_SET_PDEATHSIG.The design
compile_posture.CompilePosture— one fact, declared by the entry that knows (local_serveis the only site in the tree that saysUSER_MACHINE), ridingMintRequestas a typed field besidevram_cap_bytes. Not an env var (§1.17: an env may carry a VALUE, not a DECISION). Not derived fromlocal_cell_store.trust_class()orpublisher is None— both are facts about the SINK, and a rented community-cloud pod matches both while having nobody sitting at it; nor fromworker_goals, which says what a pod was bought to do. All three proxies are fenced by a test, because pgw#1127 §2's own warning is "two derivations of one fact".vcpus - 2min(vcpus - 2, vcpus/2)CPUS_PER_ENTRY_WORKER=2is an AVERAGE; at the burst a pod asks for ~2x the box, correct when the box is ours. Halving makes the burst ask for the machine, not double it. 4-core laptop → K=1; 32-core workstation → 8 by cores, 4 by ceiling.cc1plus, K inductor caches, K page-cache working sets — and that disk is the user's.MemAvailablereports the user's page cache as free.Rejected, with reasons (in the module docstring): an interactivity probe — cross-platform mess, and wrong in the case that matters, since a developer running a build in a terminal generates no input events;
nicealready IS the yield.ionice— no stdlib wrapper, and a no-op on thenone/mq-deadlineschedulers desktops ship; the RAM reserve and entry ceiling bound the I/O by bounding the writers. A third posture for community cloud — untrusted hardware rented by the second with nobody on it compiles as FLEET, deliberately.Nice is applied by the CHILD to itself, never through
preexec_fn—arm_parent_death_signal's docstring already writes down the hazard (apreexec_fnforcesfork()overposix_spawn()for a process with live gRPC threads andpthread_atforkhandlers). An AST fence keeps it that way; it is also the coordination point with the parked pgw#1111 lane, whose WIP took thepreexec_fnroute.What a user now sees
The frames still reach the hub activity unchanged; the terminal watcher is an additional sink a fleet mint never passes.
Interruptibility
The mint child arms
PR_SET_PDEATHSIGon a user machine, so a closed terminal no longer leaves a detached full-speed compile tree. Nothing is wasted:aot_resume's cross-attempt bank is already sited outside the per-attempt workdir (mint_delegate.py:312), and a test pins that — otherwise "Ctrl-C is safe" becomes a lie.The pod does not regress
FLEETis the struct default everywhere, so no fleet caller changed.test_a_POD_width_is_arithmetically_unchanged_by_this_issuecompares every bound against an independent re-implementation of the pre-issue formula over six pod shapes (modest pod, fat H100, widest pod, CPU-only cell, operator-forced narrow, RAM-bound small) — a non-regression test that asked the new code whether it changed could only answer no.RED-first
The file is a collection error on
origin/master(36/36), and each behavioural claim is additionally mutation-proven individually on this branch:local_servedeclaresFLEET..._DECLARES_the_user_machine_posturenice_level()always 0..._mint_child_NICES_ITSELFentry_ceiling()never narrows..._entry_CEILING_halves_...rss_reserve_bytes()never raises..._leaves_more_HOST_RAM_alonecpu_budget_cores()never halves..._takes_at_most_HALF_the_cores..._DIES_WITH_ITS_PARENT..._never_displaces_the_HUB_activity..._SAYS_which_posture_chose_KGates
mypy clean (266 files), ruff clean, all eight lint guards pass, changelog fragment checks. 36 new rows + the 15 pgw#1127 fence rows green.
$0: no pods, no mints, no GPU.Coordination
1111-mint-parallelism-restore, PARKED at547b6d81, not a PR) has a WIPnice_children+preexec_fnonEntryCompilePool. This supersedes that half: the posture lives on the request, the nice happens in the child, and the AST fence refusespreexec_fn. Its owed items (a)/(b)/(c) — the meta round-trip and unclamping K — are untouched and still theirs; when they land, the entry children inherit this nice for free.aot_mint.py(pgw#1132's surface) orstructure_only.py.Still open on pgw#1127
Items 5 (memo-sweep user surface), 7 (durable store root on community cloud, tensorhub) and 8 (the two-run pod proof).