Skip to content

Conversation

roberth
Copy link
Member

@roberth roberth commented Mar 12, 2024

Motivation

Refactor and improve performance.

The refactor is good in its own right, and may serve as a step towards #273815 as well as modularization that eventually benefits RFC 92 dynamic derivations and multi-derivation packages (e.g. separate derivation for the doc output).

Performance

  • -4% cpu time, based on ofborg stats across 2 runs, which may have some noise
  • supported by reduction in total allocation, but slightly diminished by final heap size
  • metrics correlating to number of operations are generally down, such as function calls

Review by commit

  • Commits 1 and 2 change the structure of the file to return an attrset "library" of one function.

  • Commits 3 and 4 were developed in Proof of concept, refactor/extract makeDerivationArgument #295105 with a more meticulous commit history, but reapplied "in one go" using the original file text for a cleaner diff and git blame. I.e. the small, safe steps can be traced back there.

  • The subsequent commits are individual pure refactors without changes in behavior.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: stdenv Standard environment label Mar 12, 2024
@roberth roberth added the 8.has: clean-up This PR removes packages or removes other cruft label Mar 12, 2024
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Mar 12, 2024
@roberth roberth marked this pull request as ready for review March 12, 2024 18:36
@roberth roberth requested a review from Ericson2314 as a code owner March 12, 2024 18:36
Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

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

Let's go!

@roberth roberth merged commit 09364e2 into NixOS:master Mar 14, 2024
@arcnmx
Copy link
Member

arcnmx commented Mar 16, 2024

I believe this change may have broke config.checkMetaRecursively?

let
  pkgs = import <nixpkgs> {
    config.checkMetaRecursively = true;
  };
  testdrv = pkgs.stdenv.mkDerivation {
    name = "hi";
    buildCommand = ''
      touch $out
    '';
  };
in testdrv

:; nix eval --json --impure -f test.nix meta
error: attribute 'nativeBuildInputs' missing
at pkgs/stdenv/generic/make-derivation.nix:559:18:
559| references = attrs.nativeBuildInputs ++ attrs.buildInputs

roberth added a commit that referenced this pull request Mar 17, 2024
Oddly, I can't reproduce the error, but this change will make it
more robust.
See #295378 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: stdenv Standard environment 8.has: clean-up This PR removes packages or removes other cruft 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants