Skip to content

Allow bind-mounting regular files into the chroot - #143

Closed
shlevy wants to merge 1 commit into
NixOS:masterfrom
shlevy:bind-files-in-chroot
Closed

shlevy wants to merge 1 commit into
NixOS:masterfrom
shlevy:bind-files-in-chroot

Conversation

@shlevy

@shlevy shlevy commented Jul 12, 2013

Copy link
Copy Markdown
Member

mount(2) with MS_BIND allows mounting a regular file on top of a regular
file, so there's no reason to only bind directories. This allows finer
control over just which files are and aren't included in the chroot
without having to build symlink trees or the like.

Signed-off-by: Shea Levy [email protected]

@edolstra

Copy link
Copy Markdown
Member

What finer control? You either have a store path in the chroot or you don't.

@shlevy

shlevy commented Jul 12, 2013

Copy link
Copy Markdown
Member Author

Suppose I have a normal (i.e. non-NixOS) /bin directory with a bunch of binaries. With this change, I can just put /bin/sh instead of /bin in build-chroot-dirs (and obviously would need to include the individual libraries too).

@edolstra

Copy link
Copy Markdown
Member

Mounting regular files doesn't seem to scale very well (on Linux 3.9 at least). Seems to take O(n^2) or so...

@shlevy

shlevy commented Jul 12, 2013

Copy link
Copy Markdown
Member Author

If we don't change the inputPaths handling (that is, keep it at hard-linking with a fallback to copying when an inputPath is a file), will that be better? It will mean this change only adds functionality, and only when requested by the administrator.

@edolstra

Copy link
Copy Markdown
Member

Yes, then it's fine.

mount(2) with MS_BIND allows mounting a regular file on top of a regular
file, so there's no reason to only bind directories. This allows finer
control over just which files are and aren't included in the chroot
without having to build symlink trees or the like.

Signed-off-by: Shea Levy <[email protected]>
@shlevy

shlevy commented Jul 12, 2013

Copy link
Copy Markdown
Member Author

Updated

@edolstra

Copy link
Copy Markdown
Member

Applied.

@edolstra edolstra closed this Jul 15, 2013
tebowy pushed a commit to tebowy/nix that referenced this pull request Jul 11, 2024
not doing this exposes the binding name order to the annoying
interference of parse order on symbol order, which wouldn't be so bad if
it didn't make the tests less reliable and, importantly, dependent on
linker behavior (due to primop initialization being done in static
initializer, and the order of static initializers being defined only
within a single translation unit).

fixes NixOS#143

Change-Id: I3cf417893fbcf19e9ad3ff8986deb7cbcf3ca511
ConnorBaker pushed a commit to ConnorBaker/nix that referenced this pull request Jul 25, 2025
…ab4e71d-c221-4d61-ab5e-4467bcc86717

Release v3.8.1
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 22, 2026
Two adversarial-review and two pattern-discovery passes (Opus 4.7, 1M ctx,
~5,300 lines under doc/inventory/review/) walked the existing 217-entry
catalog and found cross-shard patterns the per-shard catalogers couldn't
see. This commit folds the four reports into the catalog.

Catalog scope rewrite. The README's "Performance work without duplication
or complexity to fix" exclusion was wrong: hot-path container choices,
allocations in inner loops, cache-line alignment costs, and missed
concurrency are all in scope on their own merits. Same for modernisation:
shrinking the Boost dependency surface or migrating hand-rolled idioms
to stdlib equivalents is a real simplification, even when no underlying
duplication backs the change. The README "What this catalog targets"
section adds an explicit "Performance" bullet and rewrites the
modernisation bullet to be in scope; the anti-list now excludes only
cosmetic changes and feature additions.

Verdict-table corrections. NixOS#50 (resolved-by-design) and NixOS#148 (INVALID,
windowSize destruction-order hazard) had verdict-table rows that
contradicted their validation paragraphs; tables now match. NixOS#171
upgraded VALID per the scope rewrite. Section-17 header updated from
"Five VALID; nine PARTIALLY VALID" to "Six VALID; eight PARTIALLY
VALID" to track.

Reclassifications and corrections from the deeper passes:

- NixOS#140 reframed as dead code (zero callers anywhere; not a SIOF
  hazard as the original framing suggested).
- NixOS#149 mechanism corrected: the `created = 123;` debug field is a
  guard against gcc bug 80431 miscompilation, not a use-after-free
  sentinel as pass-1 had stated.
- NixOS#170 corrected to three Goal subclasses + Waker (not four Goal
  subclasses as the catalog body had said).
- NixOS#147 demoted to PARTIALLY VALID; the singleton-leak path is
  load-bearing for legacy callers and must be retained alongside
  any per-Store ownership migration.
- NixOS#122 expanded with two ABI hazards the prior reviewer missed:
  layout drift in `PrimOp::impl` (allocated by `nix_alloc_primop`
  C-API) and symbol-mangle break in `extern fun<...>
  stackOverflowHandler`.
- NixOS#138 expanded: two C-API readers of `settings.readOnlyMode`, not
  one as pass-1 had stated.
- NixOS#160 expanded with HALO-incompatibility hazard for any
  `boost::asio::awaitable<T>` migration that touches `final_awaiter`.
- NixOS#129 expanded with destructor-throw caveat for the
  `MaintainCount` -> `Finally` replacement.
- NixOS#143 expanded with TLS-fallback shutdown-ordering hazard.
- NixOS#56 reframed as a real ODR fix: different TUs previously saw
  different definitions of the explicit specialisation; the values
  coincidentally matched so behaviour was preserved but the program
  was technically ill-formed.

Count corrections (each verified independently via grep): NixOS#137 register
sites = 16 (15 production + 1 test), NixOS#166 forward-decl headers =
9/21/12 (Store +2 over the catalog body), NixOS#167 buffer-size literals =
10 in libutil / 19 tree-wide, NixOS#169 friend declarations = 16 (one
duplicate `ExprVar`), NixOS#172 `unreachable()` sites = 64-65, NixOS#173 pragma
sites = 10, NixOS#176 daemon cases = 37 (35 distinct bodies), NixOS#178
trust-check sites = 11+1, NixOS#146 env vars = 14 in src/.

Forty-four cross-shard candidates (N1-N44) folded into four new section
files (22-25). The N-numbered range is intentionally separate from
1-217 to keep cross-references stable. Pattern clusters A-G,
architectural debt themes A1-A7, C++23/Boost uplift series U1-U10
(with U7 split per pass-2's refinement), and ten redundant-abstraction
pairs R1-R10 are documented in new README subsections.

Eight follow-up agents (E1-E8) deferred for source-level investigation:
verify `impureOutputHash` deletion path, audit C-API `*Settings`
surface lockstep, write a Goal::Co property test pinning O(1) frame
depth, build a daemon-client error-message preservation matrix, set up
periodic branch verification, validate test-support consolidation,
audit forward-decl source-compat, and choose the
`vTrue`/`vFalse`/`vNull`/`vEmptyList` invariant.

The four review reports plus the consolidation log live under
doc/inventory/review/ and stay in-tree for traceability.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
angerman added a commit to angerman/nix that referenced this pull request Aug 5, 2026
…precision is the bottleneck

De-risks the keystone of ARCH_BEAT_TW_PROGRAM before the speculative-strictness
build.  Added LambdaDescriptor::strictArgsMask (runtime mirror of ir::Function::
strictArgs; foundational for Change 1) + NIX_V3_STRICT_CEILING instrument (gated;
counts closure-arg thunks that are statically-proven-strict vs actually-forced-at-
runtime, via a side-set to the force-entry).

Findings (cache-off; firefox / M5):
- static strictArgs proves strict: 142 (0.1%) / 64 (0.03%) of thunk-args.
- actually FORCED at runtime: 100,781 (58.6%) / 134,310 (69.8%).
  => the static analysis captures ~0.1% of the realizable opportunity.
- KILLS the hypothesis "extend the static pass to dynamic callees" — the static
  analysis itself proves almost nothing (needs every-path-forces-before-branch).
  The right mechanism is RUNTIME SPECULATION (observe-force + guard + deopt), NixOS#143.
- Opportunity is REAL but MODEST: ~3.5% of firefox's 2.88M thunks (direct-call
  path; undercounts curried PAPs).  Most thunks are lazy DATA (attrs/lists/let;
  65.7% never forced) where eager eval is UNSAFE -> strictness is structurally
  bounded to the call-arg + known-strict-operand fraction.
- Re-scopes Change 1 to a modest single-digit-% lever; bigger CPU/RSS levers stay
  HAMT (NixOS#2) + JIT (NixOS#4).  Refines the NixOS#141 gate (proceed only if prototype beats
  the darwin-4 noise floor; else ship only NixOS#142 and shift weight to NixOS#2/NixOS#4).

strictArgsMask is NOT serialized (default-0 on cache load = conservative), so no
on-disk format change.
CACHE-COHERENCE-EXEMPT: strictArgsMask is recomputed at emit, never written to or
read from the disk cache (deserialize default-constructs it to 0); on-disk
LambdaDescriptor format is unchanged.

lode/C1_P01_STRICT_CEILING_2026-06-23.md.

Copyright (c) 2026 Moritz Angermann <[email protected]>, Input Output
Group. SPDX-License-Identifier: Apache-2.0
angerman added a commit to angerman/nix that referenced this pull request Aug 5, 2026
…; P0.1 scaffold retired

Kills hypothesis: "speculative strictness is a worthwhile CPU+RSS lever."

Gate decided on measurement (a prototype can only land below the ceiling):
- NixOS#140 ceiling: call-arg forced-thunks = 100K(ff)/134K(M5) = ~3.5% of thunks.
- NixOS#141 A/B (NO_FUNC_STRICTNESS + NO_STRICT_CALL_UNTHUNK): existing static
  strictness eliminates only 9,342 thunks (0.32%) on firefox (2,889,344 ->
  2,880,002).
- Projection: full 3.5% ceiling ≈ 0.4% RSS / ~1% CPU = at/below the darwin-4
  noise floor.  NixOS#142's target (if-cond/operands) is already force-in-place (never
  MkThunk'd).  The 0.32%->3.5% residual needs optimistic-eval machinery (pure
  speculation is un-deoptable-unsafe) for ~1% gross.  Cost/benefit fails.

RE-SCOPE Change 1 (NixOS#141-144): existing static strictness stays (the realized win);
NixOS#143/NixOS#142 KILLed; nothing further to ship.  Shift weight to Change 2 (HAMT,
attacks countDistinct 16-17% + Bindings 142MB) + Change 4 (JIT).  Confirms the
thesis check: thunks are dominated by lazy DATA (65.7% unforced) that strictness
cannot touch -> the data structure (HAMT) + native codegen (JIT) close the gap.

Retires the P0.1 scaffold per Rule 0 (re-scope -> delete): reverts
LambdaDescriptor::strictArgsMask + the NIX_V3_STRICT_CEILING instrument.
hello.drvPath byte-id; ABI rebuild of v3-smoke.

lode/C1_P02_VERDICT_2026-06-23.md.

Copyright (c) 2026 Moritz Angermann <[email protected]>, Input Output
Group. SPDX-License-Identifier: Apache-2.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants