Skip to content

minimal-bootstrap: only create one derivation for mes sources - #519568

Merged
pyrox0 merged 2 commits into
NixOS:stagingfrom
llakala:minimal-bootstrap-cleanups
Jun 14, 2026
Merged

pyrox0 merged 2 commits into
NixOS:stagingfrom
llakala:minimal-bootstrap-cleanups

Conversation

@llakala

@llakala llakala commented May 12, 2026

Copy link
Copy Markdown
Contributor

Patch from #496226, slightly modified to fix a build failure. I built gcc locally, and can confirm that even though the derivation hash differs, the output is identical. This will lead to a mass rebuild, but that's only because we don't have good content-addressed derivations.

Stats for pkgs.git see an excellent improvement:

{
  "attrset": {
    "lookups": "-10.01%",
    "merges": "-16.67%",
    "mergeCopies": "-0.93%"
  },
  "list": {
    "concats": "-1.83%"
  },
  "parser": {
    "expressions": "+0.01%"
  },
  "memory": {
    "envs": "-7.42%",
    "list": "-15.47%",
    "sets": "-2.03%",
    "symbols": "+0.01%",
    "values": "-3.65%",
    "total": "-2.98%"
  },
  "speed": {
    "primops": "-8.02%",
    "functionCalls": "-8.68%",
    "thunksMade": "-6.49%",
    "thunksAvoided": "-7.91%"
  }
}

Eval stats typcally demonstrate that something has improved, but not to what degree. So here's hyperfine before:

❯ hyperfine -N --warmup 50 --runs 50 "nix-instantiate --eval -E '(import ./. {}).git.outPath'"
Benchmark 1: nix-instantiate --eval -E '(import ./. {}).git.outPath'
  Time (mean ± σ):     428.5 ms ±   9.9 ms    [User: 336.3 ms, System: 88.2 ms]
  Range (min … max):   415.0 ms … 448.8 ms    5

And after:

❯ hyperfine -N --warmup 50 --runs 50 "nix-instantiate --eval -E '(import ./. {}).git.outPath'"
Benchmark 1: nix-instantiate --eval -E '(import ./. {}).git.outPath'
  Time (mean ± σ):     395.8 ms ±   5.0 ms    [User: 311.2 ms, System: 81.9 ms]
  Range (min … max):   388.0 ms … 411.1 ms    50 runs

Plugging this into 2PropZInt in a TI84, we get a p-value of 1.001 * 10^-10 (or 0.0000000001001) for the null hypothesis. There could of course be other factors at play, but I have enough evidence to reject the null and conclude the alternative.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

@llakala
llakala force-pushed the minimal-bootstrap-cleanups branch from 619f4ea to d0c02a7 Compare May 12, 2026 22:37
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. labels May 12, 2026

@Gskartwii Gskartwii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, I forgot about this one! Maybe we could backport this for 26.05 eventually as well.

@nixpkgs-ci nixpkgs-ci Bot added 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels May 13, 2026
@siraben

siraben commented May 13, 2026 •

Copy link
Copy Markdown
Member

Ran NIX_SHOW_STATS benchmarks on this PR (f9f91c13f378) vs its base (49259c53da90, parent of d0c02a72b153).

Linux desktop 7.0.1 #1-NixOS SMP PREEMPT_DYNAMIC x86_64 GNU/Linux
AMD Ryzen 9 5950X 16-Core Processor, 128 GB RAM
nix (Nix) 2.32.1
# hello.drvPath
NIX_SHOW_STATS=1 NIX_SHOW_STATS_PATH=stats.json \
  nix-instantiate --eval --strict -E '(import ./. {}).hello.drvPath' >/dev/null

# git.drvPath  (matches the workload you used for the stats diff in the PR body)
NIX_SHOW_STATS=1 NIX_SHOW_STATS_PATH=stats.json \
  nix-instantiate --eval --strict -E '(import ./. {}).git.drvPath' >/dev/null

# minimal NixOS system eval
NIX_SHOW_STATS=1 NIX_SHOW_STATS_PATH=stats.json \
  nix-instantiate -I nixpkgs=. --eval -E '
    let nixos = import ./nixos/lib/eval-config.nix {
      modules = [ ./nixos/modules/profiles/minimal.nix
        { fileSystems."/" = { device = "/dev/sda1"; fsType = "ext4"; };
          boot.loader.grub.devices = ["/dev/sda"]; } ];
    }; in nixos.config.system.build.toplevel.drvPath
  ' >/dev/null

hello.drvPath

Details
metric baseline optimized delta % change
nrFunctionCalls 97,813 77,998 -19,815 -20.26%
nrPrimOpCalls 73,311 62,418 -10,893 -14.86%
nrThunks 199,897 165,812 -34,085 -17.05%
nrAvoided 181,413 148,692 -32,721 -18.04%
nrLookups 79,314 62,338 -16,976 -21.40%
nrOpUpdates 30,583 19,078 -11,505 -37.62%
envs.number 117,435 94,029 -23,406 -19.93%
envs.bytes 2,406,864 1,958,400 -448,464 -18.63%
list.bytes 480,976 348,600 -132,376 -27.52%
list.concats 3,140 2,839 -301 -9.59%
sets.number 49,920 35,586 -14,334 -28.71%
sets.bytes 22,139,152 21,073,264 -1,065,888 -4.81%
values.number 617,228 572,380 -44,848 -7.27%
values.bytes 9,875,648 9,158,080 -717,568 -7.27%
gc.totalBytes 41,019,680 36,679,856 -4,339,824 -10.58%

git.drvPath

Details
metric baseline optimized delta % change
nrFunctionCalls 223,514 203,699 -19,815 -8.87%
nrPrimOpCalls 134,443 123,550 -10,893 -8.10%
nrThunks 489,459 455,374 -34,085 -6.96%
nrAvoided 400,597 367,876 -32,721 -8.17%
nrLookups 165,942 148,966 -16,976 -10.23%
nrOpUpdates 68,084 56,579 -11,505 -16.90%
envs.number 268,441 245,035 -23,406 -8.72%
envs.bytes 5,888,704 5,440,240 -448,464 -7.62%
list.bytes 834,944 702,568 -132,376 -15.85%
list.concats 16,423 16,122 -301 -1.83%
sets.number 103,502 89,168 -14,334 -13.85%
sets.bytes 43,799,536 42,733,648 -1,065,888 -2.43%
values.number 1,120,888 1,076,040 -44,848 -4.00%
values.bytes 17,934,208 17,216,640 -717,568 -4.00%
gc.totalBytes 78,052,080 73,715,600 -4,336,480 -5.56%

Minimal NixOS system eval

Details
metric baseline optimized delta % change
nrFunctionCalls 4,269,608 4,229,978 -39,630 -0.93%
nrPrimOpCalls 2,004,873 1,983,083 -21,790 -1.09%
nrThunks 6,359,300 6,291,123 -68,177 -1.07%
nrAvoided 5,203,535 5,138,090 -65,445 -1.26%
nrLookups 2,985,154 2,951,197 -33,957 -1.14%
nrOpUpdates 615,237 592,227 -23,010 -3.74%
envs.number 5,058,305 5,011,490 -46,815 -0.93%
envs.bytes 98,680,136 97,783,136 -897,000 -0.91%
list.bytes 11,451,192 11,186,440 -264,752 -2.31%
list.concats 174,304 173,702 -602 -0.35%
sets.number 1,520,120 1,491,442 -28,678 -1.89%
sets.bytes 211,369,568 209,236,400 -2,133,168 -1.01%
values.number 9,605,698 9,515,923 -89,775 -0.93%
values.bytes 153,691,168 152,254,768 -1,436,400 -0.93%
gc.totalBytes 530,541,424 521,650,768 -8,890,656 -1.68%

Wall-clock cpuTime (mean of N runs, same nix-instantiate invocations)

workload baseline (s) optimized (s) delta % change
hello.drvPath (n=5) 0.2917 0.2654 -0.0263 -9.03%
git.drvPath (n=5) 0.5617 0.5111 -0.0506 -9.01%
Minimal NixOS system eval (n=3) 3.4736 3.3883 -0.0853 -2.45%

llakala and others added 2 commits May 13, 2026 21:09
The result of commonMeta is never actually needed if assertValidity goes
away, and `.meta` is never accessed from the derivation. We perform a
similar optimization in stdenv.mkDerivation.
@llakala
llakala force-pushed the minimal-bootstrap-cleanups branch from f9f91c1 to a733872 Compare May 14, 2026 01:09
@llakala

llakala commented May 14, 2026

Copy link
Copy Markdown
Contributor Author

Ran NIX_SHOW_STATS benchmarks on this PR (f9f91c1) vs its base (49259c5, parent of d0c02a7).

While I appreciate the intention, if you read the PR description, you can see I've already ran and shared a lot of the same stats. CI also gives an eval comparison for the whole tree. Coming into PR comments to paste the numbers is more distracting than helpful (at least for me).

@siraben

siraben commented May 14, 2026 •

Copy link
Copy Markdown
Member

@llakala will keep that in mind for you in the future. Have collapsed them for now. For performance-related PRs I generally always run the same eval bench since different authors have different ways to evaluate reduction/improvements.

@pyrox0 pyrox0 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.

Changes look good to me, and the eval time improvements are always welcome from my side.

@nixpkgs-ci nixpkgs-ci Bot added 12.approvals: 2 This PR was reviewed and approved by two persons. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels May 17, 2026
@r-vdp

r-vdp commented May 25, 2026

Copy link
Copy Markdown
Contributor

LGTM. However, if this was made based on the PR you mentioned, then I think it's more appropriate to cherry-pick the commits from there and preserve authorship, and then add any further improvements on top.

@llakala

llakala commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

LGTM. However, if this was made based on the PR you mentioned, then I think it's more appropriate to cherry-pick the commits from there and preserve authorship, and then add any further improvements on top.

Can do if @Aleksanaa would like. IIRC, the original commit failed to build, and I needed to add changes on top of it - and I typically like each commit to be independently sane, which is why I chose to amend.

@r-vdp

r-vdp commented May 28, 2026

Copy link
Copy Markdown
Contributor

Yeah you can amend those commits, that's fine, but just keep the co-authored-by line.

@nixpkgs-ci nixpkgs-ci Bot added 12.approvals: 3+ This PR was reviewed and approved by three or more persons. and removed 12.approvals: 2 This PR was reviewed and approved by two persons. labels Jun 7, 2026
@pyrox0
pyrox0 added this pull request to the merge queue Jun 14, 2026
Merged via the queue into NixOS:staging with commit 450baff Jun 14, 2026
31 of 33 checks passed
@llakala
llakala deleted the minimal-bootstrap-cleanups branch June 14, 2026 19:11
@llakala

llakala commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks!!!

whispersofthedawn added a commit to whispersofthedawn/nixpkgs that referenced this pull request Jul 20, 2026
this was initially introduced in NixOS#494801 but accidentally reverted in
NixOS#519568.
whispersofthedawn added a commit to whispersofthedawn/nixpkgs that referenced this pull request Jul 20, 2026
this was initially introduced in NixOS#494801 but accidentally reverted in
NixOS#519568.
caass pushed a commit to caass/nixpkgs that referenced this pull request Jul 27, 2026
this was initially introduced in NixOS#494801 but accidentally reverted in
NixOS#519568.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 12.approvals: 3+ This PR was reviewed and approved by three or more persons. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants