You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Note in particular that without --drv-path it succeeds, so it's probably not an infinite recursion but hitting a limit hardcoded in nix. I'm getting the same with both nix-1.11 and 1.12.
The reason will be displayed to describe this comment to others. Learn more.
At the moment I cannot think of any reason why this is occurring. The earlier introduced requiredPythonModules does (quite) some recursion, and this is one additional item that it tries to recurse into.
The reason will be displayed to describe this comment to others. Learn more.
@FRidh Would you be able to figure out a better fix for that? At least it would be possible to treat setuptools as a special case in hasPythonModule (ugly but would fix regression until better fix).
The reason will be displayed to describe this comment to others. Learn more.
Running both Nix 1.11.15 and Nix from today's master as nix-env -f . -qa --show-trace --drv-path -vvvvv >/dev/null on 859dc02 terminates with nix-env.log.
The reason will be displayed to describe this comment to others. Learn more.
I think adding it instead to the passthru should solve the issue. buildPythonPackage and toPythonModule also add it to the passthru. In that case it won't end up in I think drvAttrs and as such also not in the passAsFile.
Currently, the function requiredPythonModules looks like this
# Get list of required Python modules given a list of derivations.
requiredPythonModules = drvs: let
filterNull = list: filter (x: !isNull x) list;
conditionalGetRecurse = attr: condition: drv: let f = conditionalGetRecurse attr condition; in
(if (condition drv) then unique [drv]++(concatMap f (filterNull(getAttr attr drv))) else []);
_required = drv: conditionalGetRecurse "propagatedBuildInputs" hasPythonModule drv;
in [python] ++ (unique (concatMap _required (filterNull drvs)));
jupyter depends on notebook. The function is quite naive, not taking account that one leaf is in fact covered in the other. Writing
Nix lacks tail call optimization (NixOS/nix#1150) and I think that's why we're getting these stack overflows. All buildPythonPackages derivations depend on setuptools so I think that was the drop that caused the overflow.
When increasing my stack limit from 8192 to 16384 the issue did not occur. That actually makes me wonder how much stack "space" we have left when evaluating the package set, considering the use also of fixed-point combinators.
I suppose what needs to be done is writing requiredPythonModules in such a way that it traverses the tree without using this much recursion.
The reason will be displayed to describe this comment to others. Learn more.
The problem clearly isn't (just) in this particular commit. I recently got an overflow on a commit that didn't have this change, preventing my nixos system from evaluating. Maybe it will be best to increase the (default) stack limit, even if we take some precaution to reduce its usage.
The reason will be displayed to describe this comment to others. Learn more.
Running that nix-env command with NIX_SHOW_STATS=1 on 6ad7967 (the last master without 40851a4) and 0f50d5a (the master with it), we can not see the maximum recursion depth, but there is a drastic change in the number of allocated values:
evaluation statistics:
- time elapsed: 19.849+ time elapsed: 21.567
size of a value: 24
size of an attr: 24
- environments allocated: 6761687 (216992488 bytes)+ environments allocated: 8910225 (268576824 bytes)- list elements: 90931824 (727454592 bytes)+ list elements: 93226674 (745813392 bytes)- list concatenations: 750765+ list concatenations: 748285- values allocated: 17074297 (409783128 bytes)+ values allocated: 24961898 (599085552 bytes)- sets allocated: 2444900 (725028328 bytes)+ sets allocated: 2438494 (724444184 bytes)- right-biased unions: 1148943+ right-biased unions: 1145597- values copied in right-biased unions: 21635026+ values copied in right-biased unions: 21619671- symbols in symbol table: 271644+ symbols in symbol table: 271580- size of symbol table: 10706516+ size of symbol table: 10705395- number of thunks: 12639646+ number of thunks: 14629691- number of thunks avoided: 11357340+ number of thunks avoided: 13443879- number of attr lookups: 6689281+ number of attr lookups: 6708048- number of primop calls: 3753242+ number of primop calls: 5754172- number of function calls: 5803498+ number of function calls: 7944800- total allocations: 2079258536 bytes+ total allocations: 2337919952 bytes- current Boehm heap size: 1715470336 bytes+ current Boehm heap size: 1849688064 bytes- total Boehm heap allocations: 2610957824 bytes+ total Boehm heap allocations: 2950226176 bytes
859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this commit introduced a "problem" for me:
My test command:
Note in particular that without
--drv-path
it succeeds, so it's probably not an infinite recursion but hitting a limit hardcoded in nix. I'm getting the same with both nix-1.11 and 1.12.859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK this is mainly problem for borg's rebuild-amount estimation. /cc @grahamc.
859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment I cannot think of any reason why this is occurring. The earlier introduced
requiredPythonModules
does (quite) some recursion, and this is one additional item that it tries to recurse into.859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hydra also does not evaluate this (as part of
pkgs/top-level/release.nix
):Let's revert and investigate.
859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted in 19b82ec, will try to debug later today.
859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't reproduce the issue.
859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FRidh Would you be able to figure out a better fix for that? At least it would be possible to treat setuptools as a special case in
hasPythonModule
(ugly but would fix regression until better fix).https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/python-packages.nix#L90
And, obviously, thanks for everyone involved. I've been happy to learn how Python tooling in nixpkgs have got better.
859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running both Nix 1.11.15 and Nix from today's master as
nix-env -f . -qa --show-trace --drv-path -vvvvv >/dev/null
on 859dc02 terminates with nix-env.log.859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think adding it instead to the
passthru
should solve the issue.buildPythonPackage
andtoPythonModule
also add it to thepassthru
. In that case it won't end up in I thinkdrvAttrs
and as such also not in thepassAsFile
.859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vcunat @orivej can you check evaluation of https://github.com/FRidh/nixpkgs/tree/setuptools-fix.
859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FRidh: infinite recursion again (tested 1.12 and 1.11).
859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
nix-env -f . -qa --show-trace --drv-path -vvvvv >/dev/null
I was able to reproduce the issue. The stack overflow is caused when creating the derivationihaskell
https://github.com/NixOS/nixpkgs/blob/staging/pkgs/top-level/all-packages.nix#L2734.This derivation requires
Currently, the function
requiredPythonModules
looks like thisjupyter
depends onnotebook
. The function is quite naive, not taking account that one leaf is in fact covered in the other. Writingstill causes a stack overflow though.
Nix lacks tail call optimization (NixOS/nix#1150) and I think that's why we're getting these stack overflows. All
buildPythonPackages
derivations depend onsetuptools
so I think that was the drop that caused the overflow.When increasing my stack limit from 8192 to 16384 the issue did not occur. That actually makes me wonder how much stack "space" we have left when evaluating the package set, considering the use also of fixed-point combinators.
I suppose what needs to be done is writing
requiredPythonModules
in such a way that it traverses the tree without using this much recursion.859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem clearly isn't (just) in this particular commit. I recently got an overflow on a commit that didn't have this change, preventing my nixos system from evaluating. Maybe it will be best to increase the (default) stack limit, even if we take some precaution to reduce its usage.
859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't expect you to remember, but do you think it was before or after 40851a4 was introduced? That was about two weeks ago on staging.
859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FRidh: it first happened on cdde22a, i.e. after that commit.
859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running that nix-env command with
NIX_SHOW_STATS=1
on 6ad7967 (the last master without 40851a4) and 0f50d5a (the master with it), we can not see the maximum recursion depth, but there is a drastic change in the number of allocated values:859dc02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have another implementation. Could you please test https://github.com/FRidh/nixpkgs/tree/pythonmodule.
Note there is a 30% increase of function calls and 50% increase of primop calls.