Proposal for new experimental feature: resource management

I have a new experimental feature proposal which could benefit from additional discussion. It modifies system features to make them consumable when a number is appended to them with a colon, in effect permitting lightweight resource management during remote builds. An implementation is available here: Implement resource-management experimental feature by lisanna-dettwyler · Pull Request #14466 · NixOS/nix · GitHub

For example, a derivation could specify in its requiredSystemFeatures mem:16, and a machines file could specify that it has mem:64 system feature. This lets you schedule remote builds in a smarter way than just the existing slots mechanism, for derivations that are memory intensive or require dedicated access to special hardware like GPUs.

6 Likes

Hyped! Even in its simplest forms, is a qualitative change, and long delayed.

This has been something I’ve been wanting for quite a while. However, do note that resource usage is not deterministic. I had an idea of tracking threads and resource usage per thread and qualifying things based on that. You could then have a range of requirements which necessarily isn’t a system feature and nix could schedule builds in a way to optimize resource usage.

2 Likes

Maybe this might dovetail with the Slurm stuff somehow.

But, even a simple, hacky version of this is enough to test the waters to see how people feel about it–and then if people like the idea (being able to declare available resources in a builder, and then having some brains about job routing) we can sort out smarter/better implementations.

(Edit: yep, the PR explicitly mentions Slurm as an alternative.)
(Edit2: …it’s the same author. :man_facepalming: derp.)