Subject: /gnu/store/.links: base16 or base32?

From: Ludovic Courtès <[email-masked]>
Date: Fri, 21 Feb 2020 22:51:28 +0100

Seen while stracing guix-daemon during GC (the “deleting unused links”
phase):

--8<---------------cut here---------------start------------->8---
unlink("/gnu/store/.links/3a16c555c7c60f9c781895eec65a31a04a6cc535fff5a381499c1a4717d8f19f") = 0
unlink("/gnu/store/.links/1mm1n1xmjb1in2sv71kpa90n5iv30h24blzfj4z0icdssbly19kh") = 0
unlink("/gnu/store/.links/4213e7fe3db934f2817fbd0fb3a74e5395736fcc7633d295c557462cae88f945") = 0
unlink("/gnu/store/.links/1g46q6yf868x7wfqnzcy4rb8r780bqi986vjvb1n7xm4ln3jizzf") = 0
unlink("/gnu/store/.links/8b261f0461a89419ee4436d11ac828fc63a4d8d6473696262d020c17758964eb") = 0
unlink("/gnu/store/.links/0znm2gdxraz3i88r3iy838d86s1zfidx8gga4kwiqcsnmaz206d6") = 0
unlink("/gnu/store/.links/f3fe1645f86a6a1effd8e4f0dfcdaef8d73c8163c96d2b2cb42e0bd7c05d9b5b") = 0
unlink("/gnu/store/.links/69a86d84c31d5b728f6d7496413bac8a0bc06c388255f0b81868066463cff80f") = 0
unlink("/gnu/store/.links/0s0bb4pkm282srrdm61fd0lf9zn7r85s370llbp616pk4j2szkhs") = 0
unlink("/gnu/store/.links/a2b0c70e4c03f3247250155d4a2cfdf6a21e03458f892f4c2a9ba861259022f6") = 0
unlink("/gnu/store/.links/5faebd1dc60adbf32b430090a29248b86c56eba4805aeedc8d99c459a28b34eb") = 0
unlink("/gnu/store/.links/8d7d77f86a32f2a0a36b508dcbdc4a44c61dec284b9dc6299a8b7d18db9938dc") = 0
unlink("/gnu/store/.links/1cjlcwkyr59apcym97zaw8r2m4ahqc11zrm51aqzvwg3b0xvchhw") = 0
unlink("/gnu/store/.links/0z9cw4h1p4cm6jp4zap9db1lh60i0ynal0dxd2f8ilzp085wb1xj") = 0
unlink("/gnu/store/.links/1vzgxm1png21gf13v5ac3494h9zshy6y35cxk38pf6dd0qimcand") = 0
unlink("/gnu/store/.links/1r8xm4j57m9h99rvv80q2wgv29p3q42ws4s2f0c3jd9a77hl2qn8") = 0
--8<---------------cut here---------------end--------------->8---

There’s an inconsistency here!

(guix store deduplication) uses base16, but optimize-store.cc does:

    /* Check if this is a known hash. */
    Path linkPath = linksDir + "/" + printHash32(hash);

… where ‘printHash32’ returns a nix-base32 string.  Oops!

The effect is just that deduplication wouldn’t work as well as it could:
results from offloaded builds would be deduplicated among them but not
against other store items.

Ludo’.