From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Marusich Subject: Re: 'guix build' and garbage collection Date: Sun, 02 Apr 2017 23:40:16 -0700 Message-ID: <871stakn8v.fsf@gmail.com> References: <878tnjk489.fsf@gmail.com> <87inmnb1ha.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58059) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuvf6-0002Vv-GC for guix-devel@gnu.org; Mon, 03 Apr 2017 02:40:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cuvf5-0003Vc-Lf for guix-devel@gnu.org; Mon, 03 Apr 2017 02:40:24 -0400 In-Reply-To: <87inmnb1ha.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Sun, 02 Apr 2017 11:30:41 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Hi Chris, > > Chris Marusich skribis: > >> I saw this in guix/scripts.build.scm: >> >> (and (build-derivations store drv mode) >> (for-each show-derivation-outputs drv) >> (for-each (cut register-root store <> <>) >> (map (lambda (drv) >> (map cdr >> (derivation->output-paths drv))) >> drv) >> roots)) >> >> Here, we build the derivations, and then we add indirect GC roots. My >> question is: what guarantee is there that the output paths will not be >> garbage collected after we build the derivations but before we add the >> indirect GC roots? > > For the duration of the connection to the build daemon, build results > are registered as GC roots, so we=E2=80=99re fine. > > You can see it in the =E2=80=98DerivationGoal=E2=80=99 constructor in lib= store/build.cc: > > /* Prevent the .chroot directory from being > garbage-collected. (See isActiveTempFile() in gc.cc.) */ > worker.store.addTempRoot(drvPath); > > Likewise in =E2=80=98SubstitutionGoal::init=E2=80=99. > > HTH, > Ludo=E2=80=99. That's exactly what I was missing. Thank you for the information. My understanding is that Nix builds derivations in a temporary directory. My understanding is that eventually, we copy the results of the build into the final, content-addressed store path. Since we don't know the final, content-addressed store path until after we calculate the hash of the output, how do we prevent that final store path from being garbage collected while the build process is running? Do we use addTempRoot to add the final, content-addressed store path as a temporary root, too? I looked in the code but couldn't figure this out. =2D-=20 Chris --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEy/WXVcvn5+/vGD+x3UCaFdgiRp0FAljh7lEACgkQ3UCaFdgi Rp2xqw//etVeKQgmxXDY74u0QBq4XpPUfbNM1/JNMRs++bY3RHjnGHRrMLLgr1p5 EW932Pp7H+UwHvw5EfBM/Rdgn8pz7P2KsktCcls+xxKOMX25pUhlwIY7fK3m4AdF /Vo7aO02N5XhjyP9kHfXeIfH/IN525vtv9/U0JJVnZwdoAz57gbPfpwCoB9n6FIW BnVtkCyjjlNdiQ1kj/Lgw5rfJCvdsEAv7AkcaB/3kCry1UPTh44wlcKkiaNiWqJv MmsCffZp8KGYvKWCAl2ylX6L2fQfTMfdO93yqtc6MJ2jf16tOh2hB/ptprfJny8z du5EyT2+T3fjpuy8EW72wVSHiTEjwzujz7q/zhU7OWYfVKWiOOHyssDb84n8Jwt5 sLpvZ0bBU7wsjk+dxemXriTcBK18nq75X1oDi97SyMWga1ogdghhpjrcXF58xfRy YUzN1m7MNeA3KwwYJU9qKPEL/Q1e2f2xU4CwoGL4lc+pEXUrV6hoW2owPFcv0Ndk ctxP8MPdLfwTUeAJ3kWpuLfYLXy+iVxvuARJFDnGhoD3nyY5il8CBE6jnTCMgNUw FPM8SvKcpaDJPoPJ67BTy6Ip18x58XinJA9CCzvRV/5fU0ZYiIBsl89fe/9WQD2+ N2J9zhtmVhojyeOfuFDzZ0LgBR0OzU/qNf4c2rt+VVfX+pZJqJo= =JfzL -----END PGP SIGNATURE----- --=-=-=--