Skip to content

nix3-build should release memory acquired for evaluation before building the derivation #10862

Open
@poscat0x04

Description

Describe the bug
I'm not sure if this counts as a bug report or feature request.

Basically currently nix build won't release the pages allocated for evaluation while waiting for nix-daemon to build the final derivation. Since evaluation can take a lot of RAM (easily on the order of a few gigabytes when evaluation a system configuration), this can cause problems if the host is memory starved an the build task is demanding.

The same issue can be mitigated by first calling nix path-info --derivation to build a .drv file (which does the evaluation part) and then calling nix-store --realise on the resulting .drv file (which does the build part). I feel like this counts as major space leak.

One way I can think of to solve this issue is to spawn a subprocess specifically for evaluation, this way the memory can be easily reclaimed by simply killing the subprocess. Not sure how hard it would be to implement though.

Expected behavior

nix build should release unused RAM before calling nix-daemon

nix-env --version output
nix-env (Nix) 2.18.2

Priorities

Add 👍 to issues you find important.

Metadata

Assignees

No one assigned

    Labels

    buglanguageThe Nix expression language; parser, interpreter, primops, evaluation, etcnew-cliRelating to the "nix" commandperformance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions