Closed cdfa closed 3 years ago
Can you compare what nix-du says with
nix-store --gc --print-live | xargs nix path-info -s | awk ' BEGIN { a = 0; } { a+=$2; } END { print a; } '
and
nix-store --gc --print-dead | xargs nix path-info -s | awk ' BEGIN { a = 0; } { a+=$2; } END { print a; } '
Can you also post the resulting graph?
Numbers have changed slightly, because I suddenly had some dead paths today somehow.
$ nix-du | tred > nix.dot
Reading dependency graph from store... 5833 nodes, 68435 edges read.
Looking for optimized paths... (this could take a long time, pass option -O0 to skip)
Size statistics for the whole store:
Alive: 598.01 MiB (0 B saved by optimisation)
Total: 8.65 GiB (not taking optimisation into account)
Computing quotient graph... 13 nodes, 23 edges.
$ nix-store --gc --print-live | xargs nix path-info -s | awk ' BEGIN { a = 0; } { a+=$2; } END { print a; } '
finding garbage collector roots...
determining live/dead paths...
9290480056
$ nix-store --gc --print-dead | xargs nix path-info -s | awk ' BEGIN { a = 0; } { a+=$2; } END { print a; } '
finding garbage collector roots...
determining live/dead paths...
error: opening file '/home/cdfa/default.nix': No such file or directory
0
nix.dot:
digraph nixstore {
graph [rankdir=LR];
node [shape=box,
style=filled
];
{
graph [rank=same];
N1 [color="#4169E1",
fontcolor="#ffffff",
label="{transient} (220 B)",
shape=tripleoctagon];
N2 [color="#FFA800",
fontcolor="#000000",
label="/nix/var/nix/profiles/per-user/root/channels-2-link (228.04 MiB)",
shape=tripleoctagon];
N3 [color="#416AE1",
fontcolor="#ffffff",
label="/nix/var/nix/profiles/default-3-link (219.39 KiB)",
shape=tripleoctagon];
N4 [color="#4169E1",
fontcolor="#ffffff",
label="/nix/var/nix/profiles/per-user/cdfa/profile-11-link (8.52 KiB)",
shape=tripleoctagon];
N5 [color="#4169E1",
fontcolor="#ffffff",
label="/nix/var/nix/profiles/per-user/cdfa/profile-12-link (10.35 KiB)",
shape=tripleoctagon];
N6 [color="#4169E1",
fontcolor="#ffffff",
label="/nix/var/nix/profiles/per-user/cdfa/profile-13-link (11.90 KiB)",
shape=tripleoctagon];
N7 [color="#4097E4",
fontcolor="#ffffff",
label="/home/cdfa/Projects/ll-node-package-example/.direnv/drv (9.45 MiB)",
shape=tripleoctagon];
}
N10 [color="#4170E1",
fontcolor="#ffffff",
label="nix-du-0.3.3 (1.19 MiB)"];
N1 -> N10;
N8 [color="#3DE4EC",
fontcolor="#000000",
label="xz-5.2.5 (32.96 MiB)"];
N3 -> N8;
N11 [color="#FF0000",
fontcolor="#000000",
label="niv-0.2.18-bin (281.96 MiB)"];
N4 -> N11;
N12 [color="#408BE3",
fontcolor="#ffffff",
label="nix-tree-0.1.1.0 (6.62 MiB)"];
N5 -> N12;
N6 -> N10;
N6 -> N12;
N9 [color="#3CEEEA",
fontcolor="#000000",
label="zlib-1.2.11 (37.54 MiB)"];
N8 -> N9;
N10 -> N8;
N11 -> N9;
N12 -> N11;
}
Of course, I can't reproduce, so I'll need some help.
First, can you check the version of nix of:
which nix
systemctl show -p ExecStart nix-daemon
ldd $(which nix-du) | grep libnix
Second, I pushed on master an option to dump the graph that nix-du reads from the nix database before any processing.
The best course of action would be to
nix-du --dump=/tmp/foo.dot >/dev/null
nix-store --gc --print-live | xargs nix path-info -s | sort -r -n -k2 | head
sudo nix-store --gc --print-roots
Of course :)
nix --version
: nix (Nix) 2.3.8
$ systemctl show --no-pager -p ExecStart nix-daemon
ExecStart={ path=/nix/store/l0jnrw6cvf1rzh99bgrhnja2d3i0g82r-nix-2.3.8/bin/nix-daemon ; argv[]=nix-daemon --daemon ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
$ ldd $(which nix-du) | grep libnix
libnixstore.so => /nix/store/l0jnrw6cvf1rzh99bgrhnja2d3i0g82r-nix-2.3.8/lib/libnixstore.so (0x00007fa18de9c000)
libnixmain.so => /nix/store/l0jnrw6cvf1rzh99bgrhnja2d3i0g82r-nix-2.3.8/lib/libnixmain.so (0x00007fa18de68000)
libnixutil.so => /nix/store/l0jnrw6cvf1rzh99bgrhnja2d3i0g82r-nix-2.3.8/lib/libnixutil.so (0x00007fa18ddb1000)
$ nix-store --gc --print-live | xargs nix path-info -s | sort -r -n -k2 | head
finding garbage collector roots...
determining live/dead paths...
/nix/store/0zfnq2gnjxlrwc2fr1frv1m1x70plgz5-ghc-8.8.4 1670437192
/nix/store/1lhnbf58h4vm0zw1xr0091qilw9rrc1v-ghc-8.8.4 1670436128
/nix/store/jrkqkdvvjvamhhy182q4gk4ckcmkg4ji-rustc-1.47.0 712172968
/nix/store/r9anmfg7pj634rq2q0fw09srjg71im24-ghc-8.8.4-doc 284367432
/nix/store/hss8cz1a6w18bwcjmfhajl2cjlkf9jsy-ghc-8.8.4-doc 284367432
/nix/store/n8b40m7r4mhivv1nqvljngbw2cx21mnb-node-sources 282855760
/nix/store/g8wz701j2z9yf5vj0nxx306zlhskynnq-node-sources 276672656
/nix/store/psshq3ajzz2j0z5260hl47i76i9p7akg-llvm-10.0.1 265842216
/nix/store/746dfcg71yl9kql0chqg7za5fkhf2wci-glibc-locales-2.31 219734944
/nix/store/r68k5h3k9zynrqyi9si09cv92bjfjm6m-haskell-src-exts-1.23.1 147854576
It took my laptop a while, but it did manage to render an svg graph after a while. It looks really cool! Furthermore, it seems to be correct. ghc-8.4.4 does appear and is linked to a valid root. What I can't figure out, is why nix-du then thinks it's dead. I uploaded the file here.
Please let me know if I can help further :)
I tried to have a look at the svg but it's not very handy. The dot format would be more useful because there is a tool to highlight the ancestors of a node in zgrviewer (only zgrviewer is able to zoom enough it seems while still being able to search for text.
the link needs a login to access it
(if you zip it, you can put it as an attachement to github, without using a third party sharing medium)
Oh derp. Didn't know about the zip file, thanks for the tip! nix-dump.zip
I had a look:
you have two copies of ghc-8.8.4.
One is pulled by hnix-0.9.1, the other by niv-0.2.18. Both have no parents which suggest they are really dead. Can you check that nix agrees:
ls /nix/store/*hnix-0.9.1
to find the store path
and then nix-store --query --roots path
and nix-store --query --referers path
?
Hmm, not entirely sure what to make of this. It belongs to the correct root but has no referers?
$ nix-store --query --roots /nix/store/0l5nkm5v7l3s6fwvhc8p07c3ckl78nyz-hnix-0.9.1/
/home/cdfa/Projects/ll-node-package-example/.direnv/drv -> /nix/store/i5v9rz4abd3akwl1rjm1a3xrjqbhyab5-nix-shell.drv
$ nix-store --query --referers /nix/store/0l5nkm5v7l3s6fwvhc8p07c3ckl78nyz-hnix-0.9.1/
/nix/store/0l5nkm5v7l3s6fwvhc8p07c3ckl78nyz-hnix-0.9.1
It belongs to a root which points to a drv, and the drv cannot depend on realised outputs, so it does not make sense. Would you mind opening an issue on nix?
Okay, so the path is really dead and nix-du is correct? I'm still not understanding completely, but I created an issue. Please feel free to suggest a better name and add to it :)
From the issue on nix, the inconsistency seems to be caused by the keep-outputs
option. Is that something nix-du takes into account?
No, nix-du does not take into account either keep-outputs or keep-derivations. I pushed a fix to master, can you test it?
Note that I wrote nix-du with the assumption that the store could not contain cycles (except self loops). But with both keep-outputs and keep-derivations set to true, a derivation and its output constistute a cycle, and I don't know what will happen...
It's a lot better, but still not quite correct I think:
Zip with a dump and output svg: nix-dump2.zip
Thanks for testing.Which commit of nix-du did you use to obtain this ? I see that a store path ghcjs-75c61af has no referrers nor references, can you check what nix-store -query --references and --referrers and --roots says about this store path ?
bump
Apologies for taking so long to respond. I've been very busy, but I was also having some nix issues.
With regards to your last comment: I'm not sure how to find the commit of nix-du I used. I did nix-env -if https://github.com/symphorien/nix-du/archive/master.tar.gz
at some point and collected garbage after, so I think the archive is deleted. It seems I have also deleted ghcjs-75c61af now. Thinking about it, I also might have had keep-outputs = false
with the last test, so this might change your interpretation of the results.
The nix issues I was mentioning have to do with nix path-info
telling me some paths are invalid, which I though might weird results, so I would garbage collect and wait a while before I would have some stuff to garbage collect again. I just checked again and there were no invalid paths, but apparently keep-outputs = true
was not in effect immediately, so the nix and nix-du output don't match 😓. I'll try to run another test soon.
I tagged a new release, I think that fixes the issue, feel free to reopen if needed.
Hi, I'm not very experienced with Nix, so the issue might be with me, but I have a problem:
nix-du
say there is almost 8GiB of dead pathsHowever,
nix-collect-garbage -d
orsudo nix-collect-garbage -d
don't clean anything.If I look at a large path that does not fit in any of the nodes in
nix.svg
and try to delete it says it's still alive and can show me by which root:The size that is computed for this root is ~9MiB. I don't think that is correct.