Description
Blocked by #54. Nothing here can be built until a worker starts by exec.
What #94 left
#94 landed Session(env=...) on both engines. It serves every name Nix reads
after initLibStore: NIX_SSHOPTS, the proxy variables, TMPDIR.
It cannot serve a name Nix reads while libnixstore loads, and it refuses
each one rather than accept a value that would do nothing.
nanopynix._env.READ_WHILE_LIBSTORE_LOADS is the list, eleven names read in
src/libstore/globals.cc of Nix 2.31, 2.34 and 2.35:
NIX_STORE_DIR, NIX_STORE, NIX_STATE_DIR, NIX_LOG_DIR, NIX_DATA_DIR,
NIX_CONF_DIR, NIX_DAEMON_SOCKET_PATH, NIX_SSL_CERT_FILE,
SSL_CERT_FILE, NIX_REMOTE_SYSTEMS, NIX_IGNORE_SYMLINK_STORE.
The reason is the same on both engines: the library is already loaded when a
session exists. The rpc worker imports the bindings in the forkserver, which
preloads nanopynix.rpc.worker._worker, and an inproc caller imported them to
construct the session at all.
An exec sets the environment before the interpreter starts. That is the one
shape that changes the answer, and it is #54.
What it would unlock
The eleven names. Eight have a first-class route today
(stores.Local(store_dir=...), NixSettings(ssl_cert_file=...) and so on), so
the gain there is a second spelling rather than a new capability. Three have no
route at all — NIX_DATA_DIR, NIX_CONF_DIR and NIX_IGNORE_SYMLINK_STORE —
and today the only place to set one is the environment of the whole process.
Session(nix_conf=...) on Nix 2.31, which is broken now. The worker sets
NIX_USER_CONF_FILES from the message, and 2.31 read that variable while
libnixstore loaded, so the assignment is a silent no-op there.
tests/support/nix_markers.py::NIX_CONF_FILE_IGNORED carries the measurement
and skips four tests in tests/nanopynix/test_config_flow.py:
test_the_substituters_of_the_host_reach_the_sessiontest_a_named_substituter_beats_the_hosttest_the_features_of_the_host_survive_beside_ourstest_an_ambient_variable_overrides_nothing_of_the_host
A stdio worker would let all four run on 2.31, and NIX_CONF_FILE_IGNORED
would be deleted rather than narrowed.
The decision this issue has to make
A stdio worker makes these names work on one start method. That
contradicts the rule #94 established, which is that the refusal set is the
union over the supported versions of Nix and gives one program one answer.
Three shapes are possible, and each costs something different:
a. Refuse unless worker_start="stdio". Nothing is silent, and the message
can name the setting that would accept the value. But the refusal set stops
being one answer for one program: the same Session(env=...) succeeds or
raises depending on a setting somewhere else.
b. Escalate to stdio when env names one of them. The name works
everywhere and the refusal set disappears. But a session silently changes start
method, and therefore silently changes cost. worker_start already documents
7.7 ms per worker for forkserver against 72.1 ms for spawn; nobody has
measured the exec.
c. Refuse always, and document stdio as the escape. The smallest change
and the one that keeps #94's rule intact. It also makes the stdio worker the
only way to say something the API otherwise refuses, which is the shape that
made this an issue in the first place.
Measure the exec before picking. The choice between (a) and (b) turns on
whether an escalation is cheap enough to be invisible, and that number does not
exist yet.
Acceptance
- The exec cost of a stdio worker is measured, beside the existing 7.7 ms and
72.1 ms figures inNanopynixSettings.worker_start. - One of (a), (b) or (c) is implemented, and the reason is in the docstring of
nanopynix._envrather than in this issue. tests/nanopynix/test_session_env.pyasserts the chosen behaviour on every
start method, not only on the default one.- If the answer is (a) or (b):
NIX_CONF_FILE_IGNOREDis deleted, and the four
tests above run on Nix 2.31.
Related
#54 blocks this. #94 is what created it. #76 item 3 wants the same exec for a
different reason.
Activity
feat(rpc): start a worker by exec, and serve its backchannel
feat(rpc): start a worker by exec, and serve its backchannel