From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 2BRDFnyv3mKhIAAAbAwnHQ (envelope-from ) for ; Mon, 25 Jul 2022 16:58:04 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id OFJLFnyv3mJXXgAAauVa8A (envelope-from ) for ; Mon, 25 Jul 2022 16:58:04 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1E8B022E8C for ; Mon, 25 Jul 2022 16:58:04 +0200 (CEST) Received: from localhost ([::1]:50474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFzX0-0008NB-Kk for larch@yhetil.org; Mon, 25 Jul 2022 10:58:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFzWX-0008N3-Mq for help-guix@gnu.org; Mon, 25 Jul 2022 10:57:33 -0400 Received: from knopi.disroot.org ([178.21.23.139]:54282) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFzWV-0008Vw-2T for help-guix@gnu.org; Mon, 25 Jul 2022 10:57:33 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id EC80340DBD; Mon, 25 Jul 2022 16:57:26 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fnBBlfLtluyB; Mon, 25 Jul 2022 16:57:25 +0200 (CEST) Mime-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1658761045; bh=axV3fFcW4OrfuHWMu+6fJw6xJX9V12kyCpp3x/DeVZQ=; h=Date:From:To:Subject:References:In-Reply-To; b=Wq0Dd72DNYMGCZyG0DV9SASr5II4yZngch36Amwtx7KXLLeeUQDVTZVGtrhPn43ST WQAW2tHXHM8nOJkCvgl4OiD5QDPX0RKj6uS/RfK6kcZvP/TH331O4bh4c6xsLKBjVo gtqT1K1qIIuoGmqJwwJU2QcLPzAwuJDW84on3Uanhbe8rYQ/4Ab0ZUPAM+CecI7bn8 z0Cww/xGjwBJUaJgzX45q9MORibMCHcVai4MJRvzmk2lIkmNQuiISMplNWrRiCnKXJ M3wvRVs0Ge5OH1Q0kEa5enyvf5TRLE5c+y9XanEoQln7c4AjFbqntY/+GctOUjjHRt WE/hKEefMtkVw== Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 25 Jul 2022 15:57:24 +0100 Message-Id: From: "(" To: "Gottfried" , Subject: Re: Garbage Collector References: In-Reply-To: Received-SPF: pass client-ip=178.21.23.139; envelope-from=paren@disroot.org; helo=knopi.disroot.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: "Help-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1658761084; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=rdo+n3+5wV/ZmWnykX2vqb7XHQxlIcUJB7WX+nvzFM0=; b=XUbEdJZGNK/KDMdK+buLUPFJP4V+FSHn7vrWY8XlnnHNqpPD1e4eSsYOTFxUtr7c87MIpE 2Spr2b0aM7utmKqG/gRJ/IBAzMiPGwzy2Etw0AqOqhh+8X+1zQPoWZNGTczElcD53894+l ZhWk00hF3EekWWdzLCQ+zyulaOXxRoXaKWZKEjyBYskxkKARG+dsnYTGbgxqBnKpG+d7al DholYnPVrHEKE81HXflgmI2Lf/VQJHsR9p54hVy357/LCzQpdgCSt4Iaj2Dod+67YGuq6h NDABBa/MwppHoskQjQyaKxXKcpXOmmH+wbVCvu+wgQtOCXCs+q0PPejS+l3sVg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1658761084; a=rsa-sha256; cv=none; b=HNgGwPRzmAXIL3jJxoNRwPRJkJZktBHi6pBZ01++G85zPh8+6PBjJ4veLrxCMQadRc6S7F tHbJ2Y3Zeq3ZMgUXp045rqUIpydO3Cfj3fVnhqX6SZMrqcJJOn3uwqJDn+bl/80eBfgChx s1Cw6dzH9rcIwn9BzgV+zH47Lo+AKMywATXYW+Es7RG/6RASQkZV+1asLoh43mx/7fYCSY VKKYMRSTv4K9OfvIlvaRSabhyn6C83yMJqgS0TH8/9yy6IGUI4uEQkICqyphXU+ITNlO/p Lx/bWKOFTY2Z031oJc6sFNS8/0F2aWt52Mw/7XVwCnWAbXmTMWdga4oem3mS0g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=disroot.org header.s=mail header.b=Wq0Dd72D; dmarc=pass (policy=quarantine) header.from=disroot.org; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -4.43 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=disroot.org header.s=mail header.b=Wq0Dd72D; dmarc=pass (policy=quarantine) header.from=disroot.org; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 1E8B022E8C X-Spam-Score: -4.43 X-Migadu-Scanner: scn0.migadu.com X-TUID: sH4vUEQehBr5 On Mon Jul 25, 2022 at 10:51 AM BST, Gottfried wrote: > The manual says that it is dangerous to use: "guix gc" > because it can delete too much. I think you're misunderstanding what the manual means, and what garbage collection entails. (Disclaimer: I'm not a Guix expert, so it's possible this explanation is partially incorrect.) The store is a massive database, containing things like outputs, derivations, and profiles. These are then symlinked into various positions in the system, for example your user's profile: =CA=83 readlink -f .guix-profile /gnu/store/vpjlpmxnfsmbzzmv15das5gzcg308cdk-profile which itself contains symlinks to subpaths of outputs: =CA=83 readlink /gnu/store/vpjlpmxnfsmbzzmv15das5gzcg308cdk-profile/bin/vim /gnu/store/kkc4ff1bxmb8qixiiy4rbc256m8l4rmz-vim-9.0.0000/bin/vim In my profile, I have two packages installed: =CA=83 guix package --list-generations Generation 1 ... aerc ... vim ... What happens if I remove `vim`? Well, we need to create an entirely new profile (which does not contain Vim things). Our .guix-profile is now linked to a completely different store path, this one without any Vim-related symlinks: =CA=83 readlink -f .guix-profile /gnu/store/22ph0mlsd83k4p6wsc6276rhsk3qanxv-profile =CA=83 ls /gnu/store/22ph0mlsd83k4p6wsc6276rhsk3qanxv-profile/bin aerc What happened to our Vim output path? Was it deleted? =CA=83 test -e /gnu/store/kkc4ff1bxmb8qixiiy4rbc256m8l4rmz-vim-9.0.0000 && = echo still exists still exists So, is it just hanging around in the store, taking up space? Not quite. As you'll probably know, Guix supports rolling back to previous generations: =CA=83 guix package --list-generations Generation 1 ... aerc ... vim ... Generation 2 ... - vim ... So Vim is actually still in use! But we've decided that we are absolutely certain that we don't want Vim. Let's delete all records of Vim's existence in our profile. =CA=83 guix package --delete-generations deleting /var/guix/profiles/per-user/paren/guix-profile-1-link And now... =CA=83 guix package --list-generations Generation 929 ... aerc ... No more Vim. =CA=83 test -e /gnu/store/kkc4ff1bxmb8qixiiy4rbc256m8l4rmz-vim-9.0.0000 && = echo still exists! still exists! What?! Vim really wants to stay alive. But it's not being used by anything anymore, not even an old profile. So, how do we vanquish it? With `guix gc` :) =CA=83 guix gc finding garbage collector roots... deleting garbage... [...] [0 MiB] deleting '/gnu/store/kkc4ff1bxmb8qixiiy4rbc256m8l4rmz-vim-9.0.0000' [...] guix gc: freed 45.94845 MiBs We did it! The Vim store path no longer exists (and neither does the Tcsh store path, which is a dependency of Vim): =CA=83 test -e /gnu/store/kkc4ff1bxmb8qixiiy4rbc256m8l4rmz-vim-9.0.0000 || = echo gone! gone! So, `guix gc` makes sure never to touch anything that's still in use. Quoting the manual, > The garbage collector has a set of known roots: any file under > /gnu/store reachable from a root is considered live and cannot be > deleted; any other file is considered dead and may be deleted. The set > of garbage collector roots (=E2=80=9CGC roots=E2=80=9D for short) include= s default user > profiles; by default, the symlinks under /var/guix/gcroots represent > these GC roots. New GC roots can be added with guix build --root, for > example (see Invoking guix build). The guix gc --list-roots command > lists them. This would make sense for a 'garbage collector'; after all, the term usually refers to a system for automatically freeing unused memory, so that it can be reused. If it were to accidentally free memory that's still in use, someone's variable would suddenly point to invalid memory! So the GC needs to be absolutely certain that nobody's using the memory. The manual does say, though, that: > Running guix gc with no arguments will collect as much garbage as it > can, but that is often inconvenient: you may find yourself having to > rebuild or re-download software that is =E2=80=9Cdead=E2=80=9D from the G= C viewpoint but > that is necessary to build other pieces of software=E2=80=94e.g., the com= piler > tool chain. And indeed, if we change our mind and decide we actually do want Vim, we have to re-download it: =CA=83 guix install vim The following package will be installed: vim 9.0.0000 [...] 7.4 MB will be downloaded [...] tcsh-6.22.03 323KiB ... vim-9.0.0000 7.1MiB ... [...] However, running `guix gc` is *never destructive or dangerous*, because that would be counter to the entire purpose of a GC. -- (