From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id EK3vDKDtM2HbKAEAgWs5BA (envelope-from ) for ; Sun, 05 Sep 2021 00:05:20 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id WK5zCKDtM2EHawAAbx9fmQ (envelope-from ) for ; Sat, 04 Sep 2021 22:05:20 +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 E2BD51AD73 for ; Sun, 5 Sep 2021 00:05:19 +0200 (CEST) Received: from localhost ([::1]:57746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMdmo-0001bs-Vt for larch@yhetil.org; Sat, 04 Sep 2021 18:05:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMdmY-0001bi-Mv for guix-patches@gnu.org; Sat, 04 Sep 2021 18:05:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:37276) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mMdmY-0002Oy-ET for guix-patches@gnu.org; Sat, 04 Sep 2021 18:05:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mMdmY-0005HU-0u for guix-patches@gnu.org; Sat, 04 Sep 2021 18:05: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: Sat, 04 Sep 2021 22:05:01 +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.163079307420262 (code B ref 50384); Sat, 04 Sep 2021 22:05:01 +0000 Received: (at 50384) by debbugs.gnu.org; 4 Sep 2021 22:04:34 +0000 Received: from localhost ([127.0.0.1]:48822 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMdm5-0005Gk-RV for submit@debbugs.gnu.org; Sat, 04 Sep 2021 18:04:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50420) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMdm5-0005GZ-22 for 50384@debbugs.gnu.org; Sat, 04 Sep 2021 18:04:33 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:46516) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMdly-0001yV-SI; Sat, 04 Sep 2021 18:04:26 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=48868 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMdly-0002GU-H8; Sat, 04 Sep 2021 18:04:26 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <8900fa8c8eef7f72fc97adc2408be26c88de7803.camel@telenet.be> Date: Sun, 05 Sep 2021 00:04:25 +0200 In-Reply-To: <8900fa8c8eef7f72fc97adc2408be26c88de7803.camel@telenet.be> (Maxime Devos's message of "Sat, 04 Sep 2021 23:17:10 +0200") Message-ID: <87tuj0xaja.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=1630793120; 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=5wOKdjN2umZq//mwBoRbmnzNedTdfpVAQiYIGwkCaqM=; b=OjzUfcYTZvTHDxuJ8auKGXGQWYCxEAfgJKGy5v2p8FopARUAhgP7tMrjB01x12EaZ/gK/r /bMReop4U17SDCFlqczo2QH8RfbG1YAeMol69HUqBnMCODHYKNJvBTS66WHowTWliCTMfj 4+gMBmqH0Dt7XKlM9AA/vSxGDH8sh7A2JQIgiktZHFK67bX7fUz/Fat9zRVLnPsf//7R+C xbijfzuZfaMKEyYqkgXVq49mhLMVll6tqDuOygfJKMs2FaPZzFBuNyHwcX5o7Zpf9TB8eI Ld4wQwIdyZLIm/dPMCsCXKSF2JbC5W326OB3gyhrYfvhSXPhuuhJI5RLNXsQZQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630793120; a=rsa-sha256; cv=none; b=MeNMiXV8WpPdj0kCBzWwQGR+HheQ3G8K3810Ca5PhRjiZMyeiqVRJabmycOvHjKSc63sc1 pFrOwOxCNNjdYzxFnDv7XxLZjx/eCJSSNsh9FtiA0i+3WM5cnL6I9zZXcBNszJ0yaMviim WB8cPC7LPIHnZ1pw0IfEfGY3swZC3vq2Zb80Skl4i6v8yBFPdVIrJyRTsLtdUX6Eg8iYx0 1zBUEgVndGFtFFpppqg5WX+DdyIv6klAq5l4GJzmX21y87wJGSpOnp9U9cQQWFsZiKQL0j JzF3TzExrseN1+eAMoF1TIiw6GqSg9MyVnVyCdZK/M4fo9sQixN7HptZZmc1dA== ARC-Authentication-Results: i=1; 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-Spam-Score: -1.42 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: E2BD51AD73 X-Spam-Score: -1.42 X-Migadu-Scanner: scn1.migadu.com X-TUID: bbpNaMTbT6EB Maxime Devos skribis: > +(define-syntax search-patch > + (lambda (s) > + "Search the patch FILE-NAME and compute its hash at expansion time > +if possible. Return #f if not found." > + (syntax-case s () > + ((_ file-name) > + (string? (syntax->datum #'file-name)) > + ;; FILE-NAME is a constant string, so the hash can be computed > + ;; in advance. > + (let ((patch (try-search-patch (syntax->datum #'file-name)))) > + (if patch > + #`(%local-patch-file file-name #,(file-hash* patch #:select= ? true)) > + (begin > + (warning (source-properties->location > + (syntax-source #'file-name)) > + (G_ "~a: patch not found at expansion time") > + (syntax->datum #'ile-name)) > + #'(%search-patch file-name))))) > + ;; FILE-NAME is variable, so the hash cannot be pre-computed. > + ((_ file-name) #'(%search-patch file-name)) > + ;; search-patch is being used used in a construct like > + ;; (map search-patch ...). > + (id (identifier? #'id) #'%search-patch)))) It=E2=80=99s clever=E2=80=A6 but also a bit evil, in that it changes the se= mantics of package files in a surprising way. Modifying foo.patch without recompiling foo.scm would lead you to still use the old foo.patch, which can be rather off-putting and error-prone IMO. To address this, =E2=80=98local-file=E2=80=99 could store the inode/mtime += 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= . :-/ Intuitively, I=E2=80=99d have imagined a cache populated at run time; it wo= uld map, say, file name/inode/mtime to a store file name. =E2=80=98add-to-stor= e=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 longer = 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 whet= her it=E2=80=99s stale. Thoughts? Ludo=E2=80=99.