Skip to content

Fix personality switching from x86_64 to i686 - #160

Closed
errge wants to merge 1 commit into
NixOS:masterfrom
errge:master
Closed

errge wants to merge 1 commit into
NixOS:masterfrom
errge:master

Conversation

@errge

@errge errge commented Aug 22, 2013

Copy link
Copy Markdown
Contributor

On Linux, Nix can build i686 packages even on x86_64 systems. It's not
enough to recognize this situation by settings.thisSystem, we also have
to consult uname(). E.g. we can be running on a i686 Debian with an
amd64 kernel. In that situation settings.thisSystem is i686-linux, but
we still need to change personality to i686 to make builds consistent.

On Linux, Nix can build i686 packages even on x86_64 systems.  It's not
enough to recognize this situation by settings.thisSystem, we also have
to consult uname().  E.g. we can be running on a i686 Debian with an
amd64 kernel.  In that situation settings.thisSystem is i686-linux, but
we still need to change personality to i686 to make builds consistent.
@vcunat

vcunat commented Aug 22, 2013

Copy link
Copy Markdown
Member

Side issue: can you elaborate/point to source where i686 is significantly better than x86_64?

@errge

errge commented Aug 23, 2013

Copy link
Copy Markdown
Contributor Author

vcunat: I'm not sure I understand your question. I never said that i686 is significantly better than amd64.

Are you asking why do I have a i686 Debian with an amd64 kernel? Well, multiple reasons. First of all, I have some machines running for 15 years, I just never changed them to amd64. Other use case are VPSes, where memory is expensive, and amd64 binaries can easily be 30-60% bigger in memory (and on disk). Memory is usually very expensive at VPS providers.

Are you asking why it's better to change personality to i686 before building? If that is the question, than I have an easy example: binutils. If you compile binutils with Nix + Nixpkgs on an i686 Debian with i686 kernel, you get different binary than compiling on i686 Debian with amd64 kernel. The configure script checks uname and acts accordingly. We don't want to have impurities like that, so we have to fix personality before building.

@vcunat

vcunat commented Aug 23, 2013

Copy link
Copy Markdown
Member

I see. I was just curious if you knew about some larger performance regressions. Memory (or consequently cache) is the main issue, I imagined. Pointers are more expensive on 64-bit.

@edolstra

Copy link
Copy Markdown
Member

Applied.

@edolstra edolstra closed this Aug 26, 2013
zolodev pushed a commit to zolodev/nix that referenced this pull request Jan 1, 2024
ConnorBaker pushed a commit to ConnorBaker/nix that referenced this pull request Aug 4, 2025
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]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 28, 2026
`src/libexpr/primops.cc:4905-4918`'s `prim_hashString` previously
forced the input string into a `NixStringContext context; //
discarded` then hashed `s` (the body) directly. After Item 1
activation, if the input carries a `SourceVirtual` placeholder, the
body string is the placeholder render `/<base32>` and the hash
becomes `hash("/<base32>")` instead of `hash(realStorePath)`. Two
evaluations of the same source produce the same wrong hash; one
pre-activation evaluation produces a different hash than post-
activation.

DetSys hit this in production (commit 823f756, "builtins.hashString:
Devirtualize lazy paths", Feb 2026, fixes determinate#160).

Cover-fix: instead of discarding the context, resolve via
`state.resolveSourceVirtualContext`, ensureLazyPathsCopied, and
`rewriteStrings` over the body before hashing.

Adds `boundary-audit-builtins-hashstring.cc`. The test asserts the
post-fix hash equals `hashString(SHA-256, resolvedStorePathText)`,
proving the cover-fix produces the same hash as if the input had
never been virtual.

11th audit boundary, all PASS. 404/404 expr unit tests pass.
183/183 functional tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 29, 2026
…4/§8.6

Folds the two source-verified review findings into the proposal (memories
aren't git-tracked):
- §8.4 CORRECTIONS: `Tree` (detached-tree-by-OID fetch) was wrongly listed
  FULLY obviated — reclassified PARTIAL (substrate built: peelToTreeOrBlob +
  recipe::TreeHandle/sourceViewTreeHandle, but zero production callers and no
  fetchTree surface takes a bare tree OID). Manifest reading: laziness sound
  but no bare-commit-SHA entry point without a flake input (same root cause).
- §8.6: gap 1 (defer-past-mount) de-staled — Item 5 has LANDED so Item 2 is
  unblocked + in-flight; honest scope narrowed (impure/relative/dirty only,
  pure eval rejects unlocked inputs in both forks). Added gap 5 (DetSys async
  .drv writer we lack) + gap 6 (narHashOf linear-scan).
- §8.7 (NEW): the re-verification provenance + verdict — we win perf + soundness
  decisively (DetSys's StorePath::random leak stream NixOS#160/NixOS#302/NixOS#299 vs our
  auditable content-keyed sigil); DetSys wins defer-past-mount + async-drv;
  tecnix obviation scorecard corrected; gap5 independently re-confirmed dormant.
- TOC entry for §8.7.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.

3 participants