!djTaTBQyWEPRQxrPTb:nixos.org

Nixpkgs Architecture Team

227 Members
https://github.com/nixpkgs-architecture, weekly public meetings on Wednesday 15:00-16:00 UTC at https://meet.jit.si/nixpkgs-architecture53 Servers

Load older messages


SenderMessageTime
3 Oct 2023
@infinisil:matrix.orginfinisil Ping John Ericson growpotkin ( Alex Ameen ) phaer DavHau 13:01:40
@infinisil:matrix.orginfinisilMeeting now in https://meet.jit.si/nixpkgs-architecture, meeting notes: https://pad.lassul.us/uIi7xeSJTW6LJUEHulZgVQ?edit13:03:36
@growpotkin:matrix.orgGrowpotkin2023-10-03-080326_503x673_scrot.png
Download 2023-10-03-080326_503x673_scrot.png
13:03:47
@Ericson2314:matrix.orgJohn Ericson I'm sorry infinisil I slept poorly on and off for a long time and just woke up. I did look at the PRs a bit yesterday and the test both state and compare approach looked rock solid (I kind of want that for all CI checks now!) 13:47:59
@infinisil:matrix.orginfinisilNo problem, glad you approve of it! :D13:49:08
@Ericson2314:matrix.orgJohn EricsonHopefully next one I am not sick and not jetlagged and can join properly!13:59:06
@infinisil:matrix.orginfinisil John Ericson: If you want to discuss it we can also just schedule an ad-hoc call :) 14:17:19
@Ericson2314:matrix.orgJohn EricsonI don't think I have to much to add, just sorry about being an AWOL team member! 14:17:55
@Ericson2314:matrix.orgJohn EricsonI can go review these things async and slap some approvals on them14:18:06
@infinisil:matrix.orginfinisil DavHau: Sorry we didn't have time today, do you have a link to check out what you wanted to show? 14:54:23
@hsngrmpf:matrix.orgDavHau

DISCLAIMER: This is just an experiment

I made this fork of nixpkgs, which uses the module system for all mkDerivation based packages. All changes are contained in the latest commit.

Done:

  • in make-derivation.nix replace call to builtins.derivation with lib.evalModules
  • declare interface using the module system
  • its based on Robert Hensing (roberth) 's WIP record type for performance reasons (submodule+freeform was quite slow)
  • the defined options are incomplete -> unknown fields default to types.raw
  • added modules argument to mkDerivation allowing user to pass extra modules (cool, but still requires calling overrideAttrs which is weird)
  • pass through .mix function for each derivation, that allows passing a single module to extend the derivation.

Example usage:

Overriding

overriding before:

firefox.overrideAttrs (old: {buildInputs = old.buildInputs or [] ++ [hello];})

overriding after:

firefox.mix {derivation.buildInputs = [hello];}
  • no need to pass function
  • no need to handle previous value
  • no need to handle default
  • no need to implement merge

Type Checking

nix-repl> firefox.mix {derivation.buildInputs = {};}
error:
[...]
       error: A definition for option `derivation.buildInputs' is not of type `list of (null or package or path)'.
       [...]

Performance

(None of these findings are thoroughly tested or statistically sound)

  • Overhead on packages with small closure is little (~10% for pkgs.hello)
  • Overhead on packages with large closure is high: (~100% for pkgs.firefox)
  • Overhead when evaluating all packages is between 100 to 200%

Other findings:

  • Increasing the number of type checked fields didn't seem to increase the overhead significantly

My main question is: What are the next steps? Is there something useful to make out of this?
Some Ideas:

  • deliver this as an overlay to allow experimentation on any nixpkgs version
  • finish the interface declaration and make a CI job for nixpkgs that does type checking for all packages (we did notice that some packages pass weird types to some fields, like a list of lists for build inputs. It just doesn't end up being a problem because of how stuff gets converted to strings in derivation)
  • do some more sophisticated benchmarks that can be reproduced and used to optimize the module system.
16:25:19
@infinisil:matrix.orginfinisil

DavHau: Nice! This would be great to have in a GitHub issue, in Matrix it's easily lost.

I'd like some more detailed benchmarks, including what exactly is being benchmarked (is it the same that ofborg uses? that would be a good indication). Also not just time (I assume that's what you measured), but also memory usage.

Just from the numbers you gave though, I think this clearly demonstrates that it's too inefficient and we really need to improve performance of the module system to make this work.

16:34:20
@roberthensing:matrix.orgRobert Hensing (roberth) Possibly overhead can be further reduced by avoiding evalModules ("types.submodule") in favor of something simpler like types.fix (types.record) but also extensible 16:34:41
@roberthensing:matrix.orgRobert Hensing (roberth)It'd be somewhere between the module system and minimod I guess16:35:06
@hsngrmpf:matrix.orgDavHauYes, I just measured the time. I haven't much experience on how to do proper benchmarks with nix. Any hints or docs regarding this are appreciated. I can look at ofborgs implementation I guess.16:38:17
@infinisil:matrix.orginfinisilHere's an example of ofborg's performance report: https://github.com/NixOS/nixpkgs/pull/258804/checks?check_run_id=1735659300916:38:34
@roberthensing:matrix.orgRobert Hensing (roberth) ofborg just renders NIX_SHOW_STATS=1, but is not a serious benchmarking tool 16:39:03
@hsngrmpf:matrix.orgDavHauConcerning the github issue, should I open one on nixpkgs-architecture? I could also open a WIP PR on nixpkgs, but the thing is based on another WIP branch of robert, therfore not sure.16:39:44
@roberthensing:matrix.orgRobert Hensing (roberth)

WIP

That PR might stall for a while until we figure out how to communicate options and other metadata like checks (TBD, infinisil) through all the types

16:41:07
@roberthensing:matrix.orgRobert Hensing (roberth) *

WIP

That PR might stall for a while until we figure out how to communicate options and other metadata like checks (TBD, infinisil) through all the composite types

16:41:18
@roberthensing:matrix.orgRobert Hensing (roberth)It's fine to include those commits in your PR. It's a point in time kind of thing anyway16:42:36
@pederbs:pvv.ntnu.nopbsds changed their profile picture.21:04:17
4 Oct 2023
@pederbs:pvv.ntnu.nopbsds changed their profile picture.22:20:24
@infinisil:matrix.orginfinisilSmall but nice: https://github.com/NixOS/nixpkgs/pull/25907422:22:24
5 Oct 2023
@cafkafk:gitter.im@cafkafk:gitter.im joined the room.10:11:38
6 Oct 2023
@infinisil:matrix.orginfinisilMerged it myself, it's small enough and I tested it well enough that I felt confident doing that :)03:35:32
9 Oct 2023
@artturin:matrix.orgArtturin infinisil: Lol your pkgs/test/nixpkgs-check-by-name/tests/package-nix-dir/pkgs/by-name/fo/foo/package.nix/default.nix pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo.nix tests cause errors in nixpkgs-lint https://github.com/nix-community/nixpkgs-lint/blob/master/src/find.rs 07:10:19
@artturin:matrix.orgArtturin * infinisil: Lol your pkgs/test/nixpkgs-check-by-name/tests/package-nix-dir/pkgs/by-name/fo/foo/package.nix/default.nix pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo.nix tests cause errors in nixpkgs-lint https://github.com/nix-community/nixpkgs-lint/blob/6af572ac6994d9919bcb54578eb8430bcbf1f6e0/src/find.rs 07:29:33
@artturin:matrix.orgArtturin *

infinisil: Lol your pkgs/test/nixpkgs-check-by-name/tests/package-nix-dir/pkgs/by-name/fo/foo/package.nix/default.nix pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo.nix tests cause errors in nixpkgs-lint https://github.com/nix-community/nixpkgs-lint/blob/6af572ac6994d9919bcb54578eb8430bcbf1f6e0/src/find.rs

fixed https://github.com/nix-community/nixpkgs-lint/commit/f56d5c4efb3bb3cdb2ab46fda8c598105d6e8af1

07:35:04
@infinisil:matrix.orginfinisil
In reply to @artturin:matrix.org

infinisil: Lol your pkgs/test/nixpkgs-check-by-name/tests/package-nix-dir/pkgs/by-name/fo/foo/package.nix/default.nix pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo.nix tests cause errors in nixpkgs-lint https://github.com/nix-community/nixpkgs-lint/blob/6af572ac6994d9919bcb54578eb8430bcbf1f6e0/src/find.rs

fixed https://github.com/nix-community/nixpkgs-lint/commit/f56d5c4efb3bb3cdb2ab46fda8c598105d6e8af1

Haha nice
07:55:42

Show newer messages


Back to Room ListRoom Version: 9