From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <guix-patches-bounces+larch=yhetil.org@gnu.org>
Received: from mp0 ([2001:41d0:8:6d80::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms0.migadu.com with LMTPS
	id SID+Mxn1iWHqKAEAgWs5BA
	(envelope-from <guix-patches-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Tue, 09 Nov 2021 05:12:09 +0100
Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp0 with LMTPS
	id AGe0Lxn1iWH2UwAA1q6Kng
	(envelope-from <guix-patches-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Tue, 09 Nov 2021 04:12:09 +0000
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 3B4128B63
	for <larch@yhetil.org>; Tue,  9 Nov 2021 05:12:09 +0100 (CET)
Received: from localhost ([::1]:40080 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <guix-patches-bounces+larch=yhetil.org@gnu.org>)
	id 1mkIUS-0005ww-1K
	for larch@yhetil.org; Mon, 08 Nov 2021 23:12:08 -0500
Received: from eggs.gnu.org ([209.51.188.92]:33054)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1mkIUM-0005wg-BE
 for guix-patches@gnu.org; Mon, 08 Nov 2021 23:12:02 -0500
Received: from debbugs.gnu.org ([209.51.188.43]:48698)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1mkIUM-0005re-31
 for guix-patches@gnu.org; Mon, 08 Nov 2021 23:12:02 -0500
Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1mkIUL-0004qu-Ur
 for guix-patches@gnu.org; Mon, 08 Nov 2021 23:12:01 -0500
X-Loop: help-debbugs@gnu.org
Subject: [bug#51427] [PATCH] nix: libstore: Do not remove unused links when
 deleting specific items.
Resent-From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: guix-patches@gnu.org
Resent-Date: Tue, 09 Nov 2021 04:12:01 +0000
Resent-Message-ID: <handler.51427.B51427.163643109418585@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 51427
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@gnu.org>
Cc: 51427@debbugs.gnu.org, Liliana Marie Prikler <liliana.prikler@gmail.com>
Received: via spool by 51427-submit@debbugs.gnu.org id=B51427.163643109418585
 (code B ref 51427); Tue, 09 Nov 2021 04:12:01 +0000
Received: (at 51427) by debbugs.gnu.org; 9 Nov 2021 04:11:34 +0000
Received: from localhost ([127.0.0.1]:60238 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1mkITu-0004ph-5R
 for submit@debbugs.gnu.org; Mon, 08 Nov 2021 23:11:34 -0500
Received: from mail-qk1-f182.google.com ([209.85.222.182]:45010)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maxim.cournoyer@gmail.com>) id 1mkITs-0004pO-M0
 for 51427@debbugs.gnu.org; Mon, 08 Nov 2021 23:11:33 -0500
Received: by mail-qk1-f182.google.com with SMTP id bj27so16003306qkb.11
 for <51427@debbugs.gnu.org>; Mon, 08 Nov 2021 20:11:32 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 
 h=from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version:content-transfer-encoding;
 bh=kLECGrFl2ZF+KKyKoR9Z1g+7lY0MK3HG1Htt0LGjF44=;
 b=jJjWWla3QSN0VxxI2EmfXpc+Sdlk3spcDX6WRhoBWsyDp+KF0e+daCgfFKc96QUmMy
 1GURApm32tSrdLy6Y1UpLeEjBFc8ZO0mG5udqfNgW1IpDDs8plAy/8udffulU35K8fGm
 bVhxBqsw7CClyCUK7bdtS20/kzTN0ryqlpUSbYdxn0zz1vV7SUCM0/1gSmTpblVLUQWz
 Ok6KN80wIM4iqyk+522yUAfm7XaGB68WkAHsTdfi2Pylohus4wFfspEaYO61N/HJ4PdE
 hEw4RfoYA4rbNHctD0V0uul4LUZ0qBXPhkvdsUQpI/GGgLuaSAWMgLKpgwv9G6+xNHko
 YmAQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to
 :message-id:user-agent:mime-version:content-transfer-encoding;
 bh=kLECGrFl2ZF+KKyKoR9Z1g+7lY0MK3HG1Htt0LGjF44=;
 b=LUVbZhB6e3boLZg+3ayWNf5fiXw45gYCyjN2hMpwXPpFinDX1tb3NoN5nDuHH5+VG+
 ds3AWhCFyIw9g1Oj26hMefeO02fwwH+BRuCIXMO9HO+2ejEtzyhtHsP1n/KR8l4qV/xy
 jGYwSPPHzgMjzbmaQ6IZgy1qPTzZI19ZXkal1BSOSC7w2IyQ1FdhtibcvkKMONQsWnJF
 /nCeqNxxAsIZjZUwy3OyqXcfH24w9Pl+UxzvDtD5IhWPGAjdvMw1MTPLmHjc+OCPEK6l
 lf5w+QFdwyPkYW/xJPdhgER7zXDyOU0Q1EJt8gNDzy94aGIEY5l4cJhneY+vbitG3502
 Npzw==
X-Gm-Message-State: AOAM531DcA1Dh0vFESEaHmIqc+2hcqL71vIxkZQg7wBUwTN1KiVReQGH
 3EqsZA2GGK4svTsWn8FgJa4f5YdseAU6Bg==
X-Google-Smtp-Source: ABdhPJxt6hJIZhrPAeuCxsi2vOtr0t0WV3ZUO4ZdmtozGrzRPf/lzx+vABCcs4j8sDoROTEgfE/ykA==
X-Received: by 2002:a37:b4b:: with SMTP id 72mr3473478qkl.79.1636431086096;
 Mon, 08 Nov 2021 20:11:26 -0800 (PST)
Received: from hurd (dsl-236-125-16.b2b2c.ca. [207.236.125.16])
 by smtp.gmail.com with ESMTPSA id h16sm897497qtx.20.2021.11.08.20.11.25
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 08 Nov 2021 20:11:25 -0800 (PST)
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
References: <20211027034918.4591-1-maxim.cournoyer@gmail.com>
 <87o8795j61.fsf@gnu.org>
 <5c2dd60acfaa7d74b7554babb3e223bc855bac8a.camel@gmail.com>
 <87h7cxp9tl.fsf@gnu.org> <87sfwg7w9z.fsf@gmail.com>
 <87ee7tmdbd.fsf@gnu.org>
Date: Mon, 08 Nov 2021 23:11:22 -0500
In-Reply-To: <87ee7tmdbd.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s
 message of "Sat, 06 Nov 2021 17:57:58 +0100")
Message-ID: <87k0hi0xzp.fsf@gmail.com>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
X-BeenThere: guix-patches@gnu.org
List-Id: <guix-patches.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>,
 <mailto:guix-patches-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/guix-patches>
List-Post: <mailto:guix-patches@gnu.org>
List-Help: <mailto:guix-patches-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>,
 <mailto:guix-patches-request@gnu.org?subject=subscribe>
Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org
Sender: "Guix-patches" <guix-patches-bounces+larch=yhetil.org@gnu.org>
X-Migadu-Flow: FLOW_IN
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org;
	s=key1; t=1636431129;
	h=from:from:sender:sender:reply-to:subject:subject:date:date:
	 message-id:message-id:to:to:cc:cc:mime-version:mime-version:
	 content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding:resent-cc:
	 resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to:
	 references:references:list-id:list-help:list-unsubscribe:
	 list-subscribe:list-post:dkim-signature;
	bh=kLECGrFl2ZF+KKyKoR9Z1g+7lY0MK3HG1Htt0LGjF44=;
	b=LfI1iLi+8WW7udBnu+sbXkRAOBHtV2/T6BhnrC8sU4vCeVuSj6/f7OIuOx751+ohEJsHDR
	kFYtqZEA1vOVCBF9S5VMk8dFR7UXJGiK4d5y9Iv7mz6QQnbMxw5lrm/aa4fqxcZtkkYfPy
	xH7mafjURuvEBSYQJnDa2gNz6k7oRObDg7/ntoG0j+U3XvplWPyNoaYbtyVmUD1215Itzj
	RCEprBYhWwStgAKqKSDKSB8Lel0eaus4snLZy30EQdNkocqs1GeFMAYqVqx/wRak5XqW/A
	rZ/bmHCFM4TdWVSIn0fvRjJJA+8aiAOk36oGqFKSAFxHCqq5NJlrQFebzRmw7Q==
ARC-Seal: i=1; s=key1; d=yhetil.org; t=1636431129; a=rsa-sha256; cv=none;
	b=V15am0eGtF2QHP2jKdovILX71OUzcnyxm4YzT0jb6u9fJhlXV6Ip3/E1vUKuiFnE0BILW4
	oxfHQZwu98gC8SUk3y2N5uExaPafcHQoHskWLscOWAA5JZ/rWOExkGuMjQjs6OY9Mv6Q3t
	403BHxNR+KghJ0TRJxQXb6OyuR8Q+BLuQvYiWGEnZyANQw1Z00xiYbpxRna4pERfP7cm/F
	Kg4NIWtyc+/juK4eYCGHLSv9/o14G7RD3qPMIoHJ8mnGaTPrEFm3GmsIag6Gey+lhEEUFa
	TZxmjAhLvSmRF1KecY44Ch+KO7cmOEDEXKfaVpWaV//VUrdYgxYESdOCkahksQ==
ARC-Authentication-Results: i=1;
	aspmx1.migadu.com;
	dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=jJjWWla3;
	dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none);
	spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org
X-Migadu-Spam-Score: -1.32
Authentication-Results: aspmx1.migadu.com;
	dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=jJjWWla3;
	dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none);
	spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org
X-Migadu-Queue-Id: 3B4128B63
X-Spam-Score: -1.32
X-Migadu-Scanner: scn0.migadu.com
X-TUID: s1FsDqaYAQAL

Hi,

Ludovic Court=C3=A8s <ludo@gnu.org> writes:

> Hi Maxim and all,
>
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> Ludovic Court=C3=A8s <ludo@gnu.org> writes:
>
> [...]
>
>>> You seem to be proposing to remove =E2=80=98-D=E2=80=99 altogether.  I =
agree it has the
>>> shortcomings you write, but I think it=E2=80=99s occasionally useful
>>> nonetheless.
>>>
>>> My proposal would be either the status quo, or removing just the one
>>> link that matters from /gnu/store/.links upon =E2=80=98-D=E2=80=99.
>>
>> The second proposal makes sense.
>
> Maybe that proposal is bogus though because you=E2=80=99d need to know th=
e hash
> of the files being removed, which means reading them=E2=80=A6

Oops :-).

>> I didn't care about freeing space, as my use case was getting around
>> corrupting an item in my store due to
>> https://issues.guix.gnu.org/51400, which the patch proposed here
>> allowed me to do without wasting hours of cleaning up links (nearly 1
>> GiB of store on spinning drives).
>
> The ideal solution as zimoun writes would be to address
> <https://issues.guix.gnu.org/24937>.

Seems there's some improvement ready, but which needs more
testing/measurements?  I'd suggest simply invoking GNU sort; if it has
many pages of program for doing what it does, it's probably doing
something fancier/faster than we can (are ready to) emulate -- for free!

> Perhaps that phase needs to be implemented using a different strategy,
> say an sqlite database that records the current link count (hoping that
> =E2=80=98SELECT * FROM links WHERE NLINKS =3D 1=E2=80=99 would be faster =
than traversing
> all of =E2=80=98.links=E2=80=99) as well as a mapping from store item to =
file hashes.

Hmm.  I'll need to dive in the problem a bit more before I can comment
on this.

> BTW, those using Btrfs can probably use =E2=80=98--disable-deduplication=
=E2=80=99 and be
> done with it.

I erroneously used to think that Btrfs could do live deduplication, but
it doesn't.  There are external tools to do out of band / batch
deduplication though [0]; so if they perform better than the guix daemon's
own dedup, perhaps we could document this way out for our Btrfs users.

[0]  https://btrfs.wiki.kernel.org/index.php/Deduplication

Thank you,

Maxim