Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow exportReferencesGraph #11791

Open
roberth opened this issue Nov 2, 2024 · 1 comment
Open

Slow exportReferencesGraph #11791

roberth opened this issue Nov 2, 2024 · 1 comment
Labels
derivation-build The process of building an individual derivation (see also sandbox label) performance store Issues and pull requests concerning the Nix store

Comments

@roberth
Copy link
Member

roberth commented Nov 2, 2024

This computeFSClosure call is very inefficient, because

  • it is called for each .drv in the closure (e.g. over 4000 times in my case)

  • it recomputes the whole closure, because the second parameter is only written to. computeFSClosure/computeClosure should probably not assume that the closure property holds for this res set; that seems risky

It seems to lead to O(n²) cost.

Perhaps these paths could be gathered up in a set, and then run computeFSClosure on that set?

It is very tempting to just set includeOutputs = true, and be done with it, but that would silently ignore missing outputs, which could lead to a build impurity if not checked.

To reproduce with Nixpkgs,

nix-build -A nixosTests.nixos-rebuild-target-host

I'll open an issue.

Originally posted in 2897286

@roberth
Copy link
Member Author

roberth commented Nov 2, 2024

I glossed over .second and return in

if (!state->res.insert(current).second) return;

It does read from the result set that way, so it's slow for a different reason.

When interrupting the daemon with gdb, it's always querying path info for prepareStructuredAttrs, anecdotally (like 8 tries).

Perhaps it could be sped up by

roberth referenced this issue Nov 2, 2024
  sure that it works as expected when you pass it a derivation.  That
  is, we have to make sure that all build-time dependencies are built,
  and that they are all in the input closure (otherwise remote builds
  might fail, for example).  This is ensured at instantiation time by
  adding all derivations and their sources to inputDrvs and inputSrcs.
@roberth roberth added performance store Issues and pull requests concerning the Nix store derivation-build The process of building an individual derivation (see also sandbox label) labels Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
derivation-build The process of building an individual derivation (see also sandbox label) performance store Issues and pull requests concerning the Nix store
Projects
None yet
Development

No branches or pull requests

1 participant