From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id SMb0ENYfOmGogwAAgWs5BA (envelope-from ) for ; Thu, 09 Sep 2021 16:53:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id +OSTDNYfOmEHUAAA1q6Kng (envelope-from ) for ; Thu, 09 Sep 2021 14:53:10 +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 6668114DAA for ; Thu, 9 Sep 2021 16:53:09 +0200 (CEST) Received: from localhost ([::1]:36532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOLQK-0002Ei-CB for larch@yhetil.org; Thu, 09 Sep 2021 10:53:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOLPG-0000w3-K8 for guix-patches@gnu.org; Thu, 09 Sep 2021 10:52:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:52663) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mOLPG-00022x-A6 for guix-patches@gnu.org; Thu, 09 Sep 2021 10:52:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mOLPG-0000NX-8n for guix-patches@gnu.org; Thu, 09 Sep 2021 10:52:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50384] [PATCH] Optimise search-patch (reducing I/O) Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 09 Sep 2021 14:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50384 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxime Devos Cc: 50384@debbugs.gnu.org Received: via spool by 50384-submit@debbugs.gnu.org id=B50384.16311990771399 (code B ref 50384); Thu, 09 Sep 2021 14:52:02 +0000 Received: (at 50384) by debbugs.gnu.org; 9 Sep 2021 14:51:17 +0000 Received: from localhost ([127.0.0.1]:35974 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mOLOX-0000MV-0L for submit@debbugs.gnu.org; Thu, 09 Sep 2021 10:51:17 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50022) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mOLOV-0000MH-5n for 50384@debbugs.gnu.org; Thu, 09 Sep 2021 10:51:15 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:34170) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOLOP-0001GS-9y; Thu, 09 Sep 2021 10:51:09 -0400 Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=47216 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOLOP-0003Xv-0d; Thu, 09 Sep 2021 10:51:09 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <8900fa8c8eef7f72fc97adc2408be26c88de7803.camel@telenet.be> <87tuj0xaja.fsf@gnu.org> <0ec7f0270fcccec730808f9210f074cd5339961f.camel@telenet.be> Date: Thu, 09 Sep 2021 16:51:07 +0200 In-Reply-To: <0ec7f0270fcccec730808f9210f074cd5339961f.camel@telenet.be> (Maxime Devos's message of "Sun, 05 Sep 2021 21:48:22 +0200") Message-ID: <87ee9xerac.fsf_-_@gnu.org> 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1631199189; 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; bh=jW5cfON9e/m1HyybXYSjy8pCpZRqqCpLolGUaMw1Vts=; b=NutzO4DX9cDaFHwd1XNwKJCytLh5y2VdxVUIcmss4JTxujH62Wib3tcCvokp9iStXPHENX zYjEVXK6fwhJRU8xVZq18IPGJBho2hOqHEUJBTYispnkwzLHuY9dHtTUB0Bz2WRELMbfRI UTUINWeCJmQYH+14YP6SanqEJzXWDRYynyRtL7o3GCW17B/PTaThwwBdbk7lv03k/aL4EQ aBADwOAvlS91FBqIKsNtVe995vhZI0G7lJ1w0mrWbztUbEalGzIV9sH3VvfdCL3cUS5hZp LsW9UHLlPaIMnG8yTAd/ful9lXhY6ZznPHEkI4GlOtx08jEzgg7KnUansyzEvw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1631199189; a=rsa-sha256; cv=none; b=EHxa86tqpcrd3/HeQe+yctShGmcM57wc8O9V873U521xs2xby5Qo9U86GhPqigOxpHAooy +xQDkzvhKnZSHoVMpXtugTK3Y4n2lFYPQ4XO21KlplhNEgcgNuYdNzoWS2CYXqWF/uVkgI Bg0kVUUtK57ZfF5y3vgG8r7uNhDw7XfudoU3I88zTGLMrdlgtIcnEuSu5R7q6PAOleX7qG z/grKQPGE9BUt9hvtblelwELChYrg3OkVw/IOswvn6QnZo2vuMpTQWBrbtXO2d+/FQFD4z dECrg6ZeQ4uA6pYPNZdZdLHmj0gFr0ZP5yeBy3NsnV8+fMU3z37BOSn0G1GdMg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=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: -2.91 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; 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: 6668114DAA X-Spam-Score: -2.91 X-Migadu-Scanner: scn0.migadu.com X-TUID: iBLe/8wywfI1 Hello, Maxime Devos skribis: >> To address this, =E2=80=98local-file=E2=80=99 could store the inode/mtim= e + computed >> store file name (rather than the SHA256). =E2=80=98local-file-compiler= =E2=80=99 would >> check whether the actual file has matching inode/mtime before returning >> the computed store file name. Problem is that inode/mtime are >> guaranteed to differ once you=E2=80=99ve run =E2=80=9Cmake install=E2=80= =9D. :-/ > > An additional problem is that 'local-file-compiler' would have to 'stat' > the file even if it is already in the store, undoing the (fairly limited?) > performance gains of this patch series. > > The dependency tracking avoids this. OK. >> Intuitively, I=E2=80=99d have imagined a cache populated at run time; it= would >> map, say, file name/inode/mtime to a store file name. =E2=80=98add-to-s= tore=E2=80=99 >> (or some wrapper above it) would check the cache and return the store >> file name directly, unless =E2=80=98valid-path?=E2=80=99 says it no long= er exists. >> Downside is that this would be a per-user cache and you=E2=80=99d still = pay the >> cost until it=E2=80=99s warm. Advantage is that you could easily tell w= hether >> it=E2=80=99s stale. >>=20 >> Thoughts? > > Intuitively, I'd have imagined doing as much as possible at compilation t= ime. Of course, but it=E2=80=99s important for the caching model to match =E2=80= =9Creality=E2=80=9D, which is that patch files live independently of the source files that refer to them. I=E2=80=99d all be fine if =E2=80=98local-file=E2=80=99 were to inline file= contents at macro-expansion time, because then we could be sure the hash and contents match (but I=E2=80=99m not saying we should do this=E2=80=A6). What we could do is have a boolean saying whether the cached value is authoritative, similar to what=E2=80=99s in (gnu packages). That way, when using ./pre-inst-env or passing a -L flag or setting GUIX_PACKAGE_PATH, the cached value would not be authoritative; we=E2=80=99d be safe, without needing ad hoc dependency tracking. Thoughts? [...] > Because fixed-output-path is now called more often, I've added a patch > optimising (guix base32). [...] > From e5dc46800597023dfc1c9d53cc6e0db2f3999022 Mon Sep 17 00:00:00 2001 > From: Maxime Devos > Date: Sat, 4 Sep 2021 15:35:51 +0200 > Subject: [PATCH v2 3/9] gexp: Allow computing the hash of the local file = in > advance. > > The new field is currently unused. The following patches will > populate and use the field to reduce the time-to-derivation > when the file is already interned in the store. > > * guix/gexp.scm > (): Add sha256 field. > (%local-file): Add sha256 argument for populating the field. > (local-file-compiler): Adjust 'match' expression. [...] > +;; repeated 'stat' calls. Allow computing the hash of the file in advan= ce, > +;; to avoid having to send the file to the daemon when it is already int= erned > +;; in the store. > (define-record-type > - (%%local-file file absolute name recursive? select?) > + (%%local-file file absolute name sha256 recursive? select?) > local-file? > (file local-file-file) ;string > (absolute %local-file-absolute-file-name) ;promise string > (name local-file-name) ;string > + (sha256 local-file-sha256) ;sha256 bytevector | #f Could we store the result of =E2=80=98fixed-output-path=E2=80=99 rather tha= n the SHA256, while we=E2=80=99re at it? Again, care must be taken because it=E2=80=99s possible to set NIX_STORE_DI= R at run time, which may invalidate the pre-computed store file name. Can we make hash/file name computation a feature of =E2=80=98local-file=E2= =80=99 rather than one of =E2=80=98search-patch=E2=80=99 as in these patches? I=E2=80=99= d rather not provide a way to override this new field. There are cases where we cannot know the value of =E2=80=98recursive?=E2=80= =99 at expansion time, for instance if the user wrote: (local-file "foo.txt" #:recursive? r) In that case, we cannot compute the hash or file name. Thanks, Ludo=E2=80=99.