Repository navigation
Description
What
Give an RPC worker a recycle policy: a stated trigger that ends the worker
process and starts another, without the caller losing its session.
Split out of #76, which built the non-GC worker this policy is for. #76
carries items 1, 2, 3 and 5 of its own list, and this issue carries item 4.
Why
A build with -Dgc=disabled allocates and never releases. nix-expr's own
package option says why that is tolerable: "we just leak memory, but this is
not as bad as it sounds so long as evaluation just takes places within
short-lived processes." A worker of the RPC engine is such a process, and the
operating system reclaims it on exit. A recycle policy is what makes the
process short-lived. Without it, a build with no collector is only usable
for a test run.
A nixpkgs evaluation allocates gigabytes. The trigger is part of this work: a
count of operations, a resident-size watermark, or both.
The part that needs a design, and not only a trigger
The worker hands out integer handles, and every one of them dies with the
process. rpc/worker/_handle_registry.py holds four kinds -- STORE,
EVAL, VALUE and LOCKED_FLAKE -- and the client refers to each by an
int64. A recycle throws all of them away.
So "a caller does not observe the recycle" is only true at a quiescent point,
and nothing on the client side tracks handle liveness today. Answer these
before any code:
- When is a recycle legal? With no live handle is the simple answer, and
it may never come true in a long session. A rule that reopens the store and
the evaluator is the other, and it has to say what happens to aValuethat
the caller still holds. - Who decides? The worker knows its own resident size; the client owns the
process and the reconnect.WorkerClient.openandclosealready hold the
spawn and the teardown (rpc/client/_pool.py), so a recycle is aclose
and anopenwith the session state replayed. - What does a caller see when the rule cannot be met? A worker that never
reaches a quiescent point still grows. Refusing to recycle silently is the
failure this policy exists to prevent.
Acceptance criteria
- A worker recycles on a stated trigger, and the trigger is a setting.
- A caller that holds no handle does not observe the recycle.
- A caller that does hold one gets a stated, tested answer. Whether that is a
replay, a refusal or an exception is the decision above. - The in-process engine is unchanged. The process is the unit of reclamation,
and only the RPC engine has a spare one.
Tests
- A test that drives a worker past its recycle trigger and proves that the
session continues, and that the process identity changed. - A test that proves the resident size of a worker returns after a recycle.
This is the test that says the design works, and without it the feature
is a process restart with no measurement behind it. - A test for each answer the decision above gives to a live handle.
Where it runs
nanopynix-tests-nix_2_34-nogc is the job that exercises this, and #76 added
it to the scheduled workflow. A recycle test against a build that still has
the collector proves the mechanism and not the reason.
Activity
test(nogc): keep an evaluator out of the pytest process without a col…
Lillecarl commentedon Oct 25, 2026
nanopynix's no-collector lanes show it in CI, run 40198439983 (commit 1f7d496). The stock
test-nogc-nix_2_35,-nix_2_34and-gitare killed at about 70–80% of the suite (exit 143, the runner shuts down), the same as on 35f706d. The newtest-nogc-determinateruns to the end and then fails 17 tests, with 416 errors, onOSError: [Errno 24] Too many open files: with no collector, nothing a store holds is ever released.Assisted-By: Claude Opus 5.5