Skip to content

Upstream tracking#165

Draft
grahamc wants to merge 3188 commits into
2.34-maintenancefrom
main
Draft

Upstream tracking#165
grahamc wants to merge 3188 commits into
2.34-maintenancefrom
main

Conversation

@grahamc

@grahamc grahamc commented Jul 31, 2025

Copy link
Copy Markdown
Member

Motivation

Not intended to be merged directly. This PR is a convenience to show the diff between upstream Nix and Determinate Nix (the main branch).

Continuation of #4.

@grahamc
grahamc requested a review from edolstra as a code owner July 31, 2025 17:14
@github-actions
github-actions Bot temporarily deployed to production July 31, 2025 17:14 Inactive
@DeterminateSystems DeterminateSystems locked as off-topic and limited conversation to collaborators Jul 31, 2025
@github-actions
github-actions Bot temporarily deployed to pull request July 31, 2025 18:20 Inactive
@github-actions
github-actions Bot temporarily deployed to production July 31, 2025 18:21 Inactive
@cole-h
cole-h marked this pull request as draft August 1, 2025 14:26
@github-actions
github-actions Bot temporarily deployed to pull request August 4, 2025 22:15 Inactive
@github-actions
github-actions Bot temporarily deployed to commit August 4, 2025 22:15 Inactive
@github-actions
github-actions Bot temporarily deployed to production August 4, 2025 22:15 Inactive
@github-actions
github-actions Bot temporarily deployed to production August 5, 2025 14:25 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request August 5, 2025 14:25 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request August 7, 2025 15:58 Inactive
@github-actions
github-actions Bot temporarily deployed to production August 7, 2025 15:58 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request August 7, 2025 23:01 Inactive
@github-actions
github-actions Bot temporarily deployed to production August 7, 2025 23:02 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request August 10, 2025 16:36 Inactive
@github-actions
github-actions Bot temporarily deployed to production August 10, 2025 16:36 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request August 10, 2025 20:06 Inactive
@github-actions
github-actions Bot temporarily deployed to production August 10, 2025 20:06 Inactive
@github-actions
github-actions Bot temporarily deployed to production August 19, 2025 15:04 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request August 19, 2025 15:04 Inactive
@github-actions
github-actions Bot temporarily deployed to production August 20, 2025 10:41 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request August 20, 2025 10:41 Inactive
@github-actions
github-actions Bot temporarily deployed to commit August 20, 2025 10:41 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request August 25, 2025 16:07 Inactive
@github-actions
github-actions Bot temporarily deployed to production August 25, 2025 16:07 Inactive
@github-actions
github-actions Bot temporarily deployed to production August 25, 2025 16:14 Inactive
edolstra and others added 30 commits July 13, 2026 20:25
fail() is marked noexcept so this does nothing.
Logging functions are often called in contexts where exceptions cannot
be handled, such as in completion callbacks or destructors. In
particular, TunnelLogger::log() could throw if the daemon client has
disconnected, which turned any printError() call in a Callback
completion handler into std::terminate() (e.g. via
HttpBinaryCacheStore::maybeDisable() when transfers are torn down
after a client hangup - Sentry issue DETERMINATE-NIX-4A).

So mark log(), logEI(), warn(), startActivity(), stopActivity() and
result() as noexcept, and make the implementations handle write
failures instead of propagating them. TunnelLogger now drops messages
when the client is gone (the connection teardown is handled elsewhere,
e.g. via MonitorFdHup); the other loggers already ignored write errors
via writeToStderr() or disabled themselves (JSONLogger).

Assisted-by: Claude Fable 5 <noreply@anthropic.com>
The primOpCalls, functionCalls and attrSelects maps were plain
unordered_flat_maps updated from evaluator threads, so running with
NIX_COUNT_CALLS=1 crashed when parallel evaluation was enabled. Turn
them into boost::concurrent_flat_maps and update them using
try_emplace_or_visit().

Also fix a pre-existing bug in printStatistics() where the
"attributes" list was built into a copy of the JSON node, so the
output always contained "attributes": null.

Assisted-by: Claude Fable 5 <noreply@anthropic.com>
is-logic-error.hh relied on <cxxabi.h> declaring the Itanium ABI RTTI
classes (__cxxabiv1::__si_class_type_info and its __base_type member).
Only libstdc++'s <cxxabi.h> does that; libc++abi keeps them in its
private, uninstalled private_typeinfo.h, so building with
-stdlib=libc++ on Linux failed with

  error: no type named '__si_class_type_info' in namespace '__cxxabiv1'

Since the layout of these classes is fixed by the Itanium C++ ABI
(https://itanium-cxx-abi.github.io/cxx-abi/abi.html#rtti) and libc++abi
exports their vtables/type infos, declare the parts we need ourselves
when not using libstdc++ headers.

(macOS was unaffected only because the interposer is Linux-only in
meson.build.)

Assisted-by: Claude Fable 5 <noreply@anthropic.com>
On macOS, calling std::set_terminate(nullptr) to restore the original
terminate handler is ineffective, since std::terminate() calls the
handler recorded in the exception. So we end up in an infinite
recursion of terminateHandler() calls, which eventually overflows the
stack, leading to an unhelpful crash report.

So instead, just call onTerminate() to print the stack trace and
abort.

(On Linux / libstdc++, std::terminate() calls the global terminate
handler so we don't have this issue.)
Off-CPU profiling showed that ~2 of 12 worker threads were idle on
average during the parallel phase of 'nix search', because work items
were only spawned after fully enumerating each attrset: while one
thread enumerated legacyPackages.x86_64-linux (~120k attributes), and
later each large package subset (pythonPackages, perlPackages, ...),
the other workers had nothing new to pick up.

Two changes:

* Spawn work items incrementally (every 256 attributes) during
  enumeration instead of in one batch at the end, so idle workers can
  start on the first attributes while enumeration continues.

* Executor::spawn(): Generate queue keys with a thread-local
  mt19937_64 instead of calling std::random_device per work item,
  which costs hundreds of cycles per call (RDRAND / /dev/urandom).
  The key only needs to spread same-priority items around the queue,
  not be cryptographically random.

At 12 eval cores (with GC disabled via GC_INITIAL_HEAP_SIZE=40G),
this reduces elapsed time from ~4.6s to ~4.3s, user CPU from ~28s to
~26s, and kernel time from ~5s to ~3.9s for 'nix search nixpkgs
--no-eval-cache fizzbuzz'.

Assisted-by: Claude Fable 5 <noreply@anthropic.com>
…661-99c5-41fc-9737-5111f5bfcb9a

Release v3.21.6
nix search: Reduce evaluator worker starvation
Followup to 8fe07ef. This didn't work
when Sentry is enabled, because it initializes OpenSSL first. So we
now call initLibUtil() before Sentry.
…-attempt

Fix disabling OpenSSL's atexit handler
…8d8-4cf0-42c3-8f25-8eee063295cf

Release v3.21.7
If `git_thread_create` failed in `ll_find_deltas` (e.g. with EAGAIN
due to transient resource exhaustion), libgit2 returned an error while
the already-created delta-search worker threads were still running.
`GitRepoImpl::flush()` would then throw and free the packbuilder,
causing the orphaned workers to crash on freed memory (DETERMINATE-NIX-66:
SIGSEGV in `git_odb_read` → `git_cache_get_raw` → `pthread_rwlock_rdlock`
during `nix flake show`).

Patch libgit2 to proceed with however many threads were successfully
created, letting the work-stealing loop redistribute the thread-less
partitions' work (stolen in their entirety, so every object is still
searched for deltas), and to fall back to the single-threaded delta
search if no threads could be created at all. Also remove a
use-after-free of the `thread_params` array on the (unlikely)
mutex lock failure path.

Assisted-by: Claude Fable 5 <noreply@anthropic.com>
Fix libgit2 ll_find_delta leaking worker threads
SIGQUIT is a user-initiated "quit with core dump" action (e.g. pressing
Ctrl-\ at a terminal), not a crash, but crashpad includes it in its set
of handled signals, so it got uploaded to Sentry as a fatal error. For
example, we received crash reports of nix sitting in the blocking stdin
read at the flake nixConfig trust prompt when the user pressed Ctrl-\.

Fix this by resetting SIGQUIT to its default disposition in initNix(),
which runs after sentry_init() has installed the crashpad handlers. We
already did this on macOS; now it's done on all platforms.

Assisted-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.