!djTaTBQyWEPRQxrPTb:nixos.org

Nixpkgs Architecture Team

233 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
19 Dec 2022
@infinisil:matrix.orginfinisilOh this shouldn't be required to benchmark this21:09:54
@growpotkin1:matrix.orggrowpotkin1my rationale was that I wanted to try multiple filesystems, and since my regular FS and the Nix Store are the only two I have on this box I was just trying both of them out.21:10:47
@growpotkin1:matrix.orggrowpotkin1but yeah agreed21:10:50
@infinisil:matrix.orginfinisil You only need to check the performance of builtins.readDir, nothing else. So essentially just a nix-instantiate --eval -E 'builtins.seq (builtins.readDir ./.) null should be enough (no need to test the sharding even) 21:11:19
@infinisil:matrix.orginfinisil * You only need to check the performance of builtins.readDir, nothing else. So essentially just a nix-instantiate --eval -E 'builtins.seq (builtins.readDir ./.) null' should be enough (no need to test the sharding even) 21:11:41
@infinisil:matrix.orginfinisil
In reply to @infinisil:matrix.org
Btw I'm gonna chill in https://meet.jit.si/nixpkgs-architecture, working on https://github.com/nixpkgs-architecture/simple-package-paths/pull/20 a bit based on what we discussed today, if anybody wants to join and help out
(offline again)
22:11:58
@infinisil:matrix.orginfinisilI made some significant changes to https://github.com/nixpkgs-architecture/simple-package-paths/pull/20 btw22:20:06
@infinisil:matrix.orginfinisilI also think the tool should be done in a separate repository, rather than https://github.com/nixpkgs-architecture/simple-package-paths/pull/2222:21:30
@infinisil:matrix.orginfinisilI'll probably move that to github.com/nixpkgs-architecture/nix-spp or so (repository/CLI name ideas appreciated)22:23:21
20 Dec 2022
@growpotkin1:matrix.orggrowpotkin1

I did the million directories test and it ran in exactly the same amount of time with and without the patch.

I think my filesystem on OSX must support some equivalent of dirents which would explain why there's no change.

15:15:40
@growpotkin1:matrix.orggrowpotkin1 So that patch in terms of optimization of readDirs is most likely just going to help filesystems that require explicit lstat on single files 15:17:07
@growpotkin1:matrix.orggrowpotkin1

In any case I'm pretty sure my performance issues were more about encryption of the Nix store.

Still, I think being able to check individual files' types is useful ; but I'd say from a practical standpoint this isn't relevant to the "simple package paths" RFC

15:21:52
@infinisil:matrix.orginfinisilCan you post a comment in https://github.com/nixpkgs-architecture/simple-package-paths/issues/17?15:23:01
@growpotkin1:matrix.orggrowpotkin1Yeah. Good news really I think15:25:38
@infinisil:matrix.orginfinisil growpotkin ( Alex Ameen ): Oh hm, we should probably also test against an all-packages.nix file 15:26:26
@infinisil:matrix.orginfinisil So you now measured that readDir is as fast on Darwin as on Linux, but it might still be that readDir for sharding is much slower than an all-packages.nix file doing the same 15:27:31
@growpotkin1:matrix.orggrowpotkin1I would say that yeah - in general, Nix is going to be slower reading a large number of small files rather than a single large file; but I'd also argue that sharding doesn't necessarily mean that we're reading more files.15:29:42
@growpotkin1:matrix.orggrowpotkin1Nix should still only read in and evaluate packages which are referred to as inputs to targets being built/installed or otherwise forced to values. Creating the package set does not cause those files to be read unless their attribute names are the result of processing the files.15:31:07
@growpotkin1:matrix.orggrowpotkin1

so:

let
  inherit (builtins.getFlake "nixpkgs") lib;
  pkgNames = ...;
  pkgs = builtins.listToAttrs ( map ( n: {
    name = n;
    value = lib.callPackagesWith pkgs ( ./unit + "/<SHARD-DIR>/${n}" );
  } ) pkgNames );
in pkgs.hello

Doesn't necessarily cause anything other than the closure of hello to be read IF we are careful in ensuring that those attribute names are explicitly formed from builtins.readDir calls as opposed to something like:

getName = ( import ./unit/<SHARD-DIR>/<PKG-DIR>/pkg-fun.nix { ... } ).meta.name;
15:38:10
@growpotkin1:matrix.orggrowpotkin1 *

so:

let
  inherit (builtins.getFlake "nixpkgs") lib;
  pkgNames = ...;  # lots of `readDir` crawling like I have in "shard-test" repo
  pkgs = builtins.listToAttrs ( map ( n: {
    name = n;
    value = lib.callPackagesWith pkgs ( ./unit + "/<SHARD-DIR>/${n}" );
  } ) pkgNames );
in pkgs.hello

Doesn't necessarily cause anything other than the closure of hello to be read IF we are careful in ensuring that those attribute names are explicitly formed from builtins.readDir calls as opposed to something like:

getName = ( import ./unit/<SHARD-DIR>/<PKG-DIR>/pkg-fun.nix { ... } ).meta.name;
15:38:55
@growpotkin1:matrix.orggrowpotkin1 *

so:

let
  inherit (builtins.getFlake "nixpkgs") lib;
  pkgNames = ...;  # lots of `readDir` crawling like I have in "shard-test" repo
  pkgs = builtins.listToAttrs ( map ( n: {
    name = n;
    value = lib.callPackagesWith pkgs ( ./unit + "/<SHARD-DIR>/${n}" );
  } ) pkgNames );
in pkgs.hello

Doesn't necessarily cause anything other than the closure of hello to be read IF we are careful in ensuring that those attribute names are explicitly formed from builtins.readDir calls as opposed to something like:

# BAD: don't do this
getName = ( import ./unit/<SHARD-DIR>/<PKG-DIR>/pkg-fun.nix { ... } ).meta.name;
15:39:23
@growpotkin1:matrix.orggrowpotkin1 in order to pull that off there are a few changes that need to be made to package names - relatively few; but I ran into them even in my shard-test repo. 15:40:24
@growpotkin1:matrix.orggrowpotkin1

for example these names throw a wrench in the approach I'm recommending:

pkgs = {
  foo = ...;
  Foo = ...;
  fOo = ...;
  FOO = ...;
};

Because on case insensitive filesystems you can't have 4 directories with those names. Instead you'd have to either make some encoding for dirnames or write the package name to some file ( which would be slow as sin ).

In the shard-test:gen.nix I had to clobber conflicting names by converting them to lowercase:

{ nixpkgs ? builtins.getFlake "nixpkgs"
, system  ? builtins.currentSystem
, lib     ? nixpkgs.lib
, pkgsFor ? nixpkgs.legacyPackages.${system}
}: let
  keep   = _: v: ( builtins.tryEval ( lib.isDerivation v ) ).success;
  drvs   = lib.filterAttrs keep pkgsFor;
  names  = builtins.attrNames drvs;
  sdirN  = c: n: builtins.substring 0 c ( lib.toLower n );  # <<< Clobbers
  shards = c: builtins.groupBy ( sdirN c ) names;
  defPkg = name: {
    name = lib.toLower name;
    value."default.nix" = ''
      { system ? builtins.currentSystem }: let
        nixpkgs = builtins.getFlake "nixpkgs/${nixpkgs.rev}";
        pkgsFor = nixpkgs.legacyPackages.''${system};
      in pkgsFor."${name}"
    '';
  };
  mkShardDir = ns: builtins.listToAttrs ( map defPkg ns );
  self = {
    unit4 = builtins.mapAttrs ( _: mkShardDir ) ( shards 4 );
    ...
    unit  = self.unit4;
  };
in self
15:45:14
@infinisil:matrix.orginfinisilOhh interesting, I haven't consider case-insensitive filesystems15:47:29
@infinisil:matrix.orginfinisil * Ohh interesting, I haven't considered case-insensitive filesystems15:47:54
@growpotkin1:matrix.orggrowpotkin1honestly my recommendation is "package names must be lowercase", "package names must not contain '.'", and "package names must not contain spaces or other non-graphical characters"15:48:17
@infinisil:matrix.orginfinisilI guess we'd just need an additional check in nixpkgs that disallows attributes that would be the same without case-sensitivity15:48:37
@growpotkin1:matrix.orggrowpotkin1 it is potentially useful to align with Nix's character restrictions for installables here; but not immediately necessary or useful ( aside from simplifying handling of legacyPackages and nix run type stuff ). 15:49:22
@infinisil:matrix.orginfinisil I don't see why . should not be allowed 15:50:04
@infinisil:matrix.orginfinisilAscii might be a good restriction too15:50:30

Show newer messages


Back to Room ListRoom Version: 9