| 27 Oct 2024 |
Artturin | https://github.com/NixOS/nix/issues/6557 | 23:24:04 |
emily | hm, so the ulimits are not inherited by child processes in general on Darwin? or just the launchd setting doesn't propagate to children somehow? | 23:25:44 |
Artturin | Setting the ulimit higher in preCheck works so the first shouldn't be true | 23:27:12 |
emily | right. | 23:27:18 |
emily | it seems like it would be more expedient to add this to stdenv for now than to spend ages trying to figure out why it's not working in Nix and how it should handle it and getting a PR in to do that. | 23:27:53 |
emily | what's the default inside the Nix sandbox on Linux? is there systemd stuff to up it from 1024 there? | 23:28:09 |
Artturin | https://github.com/NixOS/nixpkgs/blob/e4735dbdda8288aef24141f3ae8848a14f06fe08/nixos/modules/services/system/nix-daemon.nix#L200
1048576 | 23:31:12 |
Artturin | https://github.com/NixOS/nix/blob/master/misc/systemd/nix-daemon.service.in | 23:31:44 |
emily | sadly kern.maxfilesperproc is 122880 by default on Darwin 😅 | 23:32:15 |
Artturin | https://github.com/NixOS/nix/commit/2320a2f93e0aa61e8d45dcfb3fb536361a1fcb6f | 23:32:28 |
emily | so we could only go that high | 23:32:30 |
emily | In reply to @artturin:matrix.org https://github.com/NixOS/nix/commit/2320a2f93e0aa61e8d45dcfb3fb536361a1fcb6f yeah so I doubt that launchd thing works. | 23:34:17 |
emily | since it's above the system-wide per-process limit. | 23:34:22 |
emily | in fact maybe the whole Nix bug is because that setting is being ignored for being too high? unless it was happening when it was 4096 too | 23:34:39 |
Artturin | There's no numbers for the old error messages so no way to know | 23:35:42 |
emily | right | 23:36:15 |
Artturin | lovesegfault: https://github.com/NixOS/nix/pull/6645#issuecomment-1230341511 | 23:37:01 |
emily | well, it seems reasonable to set it to 4096 or 122880 in setup.sh. I don't know what the potential overheads of raising the limit are on Darwin, but I'd be surprised if they're high. | 23:37:04 |
Artturin | * lovesegfault: https://github.com/NixOS/nix/pull/6645#issuecomment-1230341511 are you still patching it yourself? | 23:37:17 |
emily | (set it if it's lower, I mean, so no change for Linux.) | 23:38:35 |
emily | doing something fancier in Nix may also be nice but one line in stdenv to avoiding hacks in Nixpkgs derivations now seems like a good trade-off. | 23:39:06 |
Artturin | yep | 23:39:20 |
emily | /*
* This structure is used for the management of descriptors. It may be
* shared by multiple processes.
*
* A process is initially started out with NDFILE descriptors [XXXstored within
* this structureXXX], selected to be enough for typical applications based on
* the historical limit of 20 open files (and the usage of descriptors by
* shells). If these descriptors are exhausted, a larger descriptor table
* may be allocated, up to a process' resource limit; [XXXthe internal arrays
* are then unusedXXX]. The initial expansion is set to NDEXTENT; each time
* it runs out, it is doubled until the resource limit is reached. NDEXTENT
* should be selected to be the biggest multiple of OFILESIZE (see below)
* that will fit in a power-of-two sized piece of memory.
*/
#define NDFILE 25 /* 125 bytes */
#define NDEXTENT 50 /* 250 bytes in 256-byte alloc. */
| 23:43:32 |
emily | thankfully XNU is open source! | 23:43:44 |
emily | so, it won't cause any memory increase out of the box to set it to 122880. | 23:43:53 |
emily | therefore it seems fine, the only risk is processes using up all of them which would be a whopping 600 KiB. | 23:44:43 |
emily | so I'll just do that. | 23:44:48 |
emily | reno: you have a macOS 11 VM, right? what's kern.maxfilesperproc there? | 23:47:44 |
emily | it turns out that it's 10240 on 10.12 so we probably can't go above that for now >:( | 23:47:55 |
Artturin | What happens when you set it above the max | 23:48:23 |