Skip to content

nix-builder: cut down eval time by 31.5% - #845

Merged
danieldk merged 2 commits into
mainfrom
improve-eval-times
Sep 24, 2026
Merged

danieldk merged 2 commits into
mainfrom
improve-eval-times

Conversation

@danieldk

@danieldk danieldk commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

I did some profiling of the build of ReLU (since it compiles with all backends) and found and fixed two hot spots:

  • The pandoc package is used by a lot of packages to convert docs. However, pandoc is written in Haskell and evaluation of pandoc evaluates a large number of packages in the Haskell package set. Resolve this by overriding pandoc with a different derivation that packages precompiled pandoc binaries. This cuts out the Haskell dependencies, removing 9.3s from the 42.6s of eval time.
  • We evaluate Cargo.lock using importCargoLock. This creates a lot of derivations (fetchurl for every crate). We prefer this over cargoHash, because it'd require updating the hash every time we make a change that touches Cargo.lock. However, we did this relatively expensive eval two times, once for kernel-builder and once for kernels. Avoid the additional evaluation by sharing the same thunk between both derivations. This removes 4.1s from the 42.6s evaluation time.

Overview of the total savings:

Step Eval time Saved % of original % of previous step
Original 42.6 s — — —
+ pandoc from upstream binaries 33.3 s 9.3 s 21.8% 21.8%
+ shared importCargoLock 29.2 s 4.1 s 9.6% 12.3%
Total 29.2 s 13.4 s 31.5% —

@danieldk
danieldk marked this pull request as ready for review September 24, 2026 10:01

@sayakpaul sayakpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neato

Comment on lines +1 to +6
{
lib,
stdenv,
fetchurl,
unzip,
}:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool

@danieldk
danieldk merged commit 2685d42 into main Sep 24, 2026
46 of 48 checks passed
@danieldk
danieldk deleted the improve-eval-times branch September 24, 2026 12:48
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