From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id uKAdOZ7sM2GfKAEAgWs5BA (envelope-from ) for ; Sun, 05 Sep 2021 00:01:02 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id sNzKNJ7sM2EvVAAAB5/wlQ (envelope-from ) for ; Sat, 04 Sep 2021 22:01:02 +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 0EBA2149B0 for ; Sun, 5 Sep 2021 00:01:02 +0200 (CEST) Received: from localhost ([::1]:57472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMdie-0001AW-8e for larch@yhetil.org; Sat, 04 Sep 2021 18:01:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMdW7-0001rj-Ey for guix-patches@gnu.org; Sat, 04 Sep 2021 17:48:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:37271) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mMdW6-0008FQ-4b for guix-patches@gnu.org; Sat, 04 Sep 2021 17:48:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mMdW5-0004sR-VZ for guix-patches@gnu.org; Sat, 04 Sep 2021 17:48:01 -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 21:48: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.163079207018728 (code B ref 50384); Sat, 04 Sep 2021 21:48:01 +0000 Received: (at 50384) by debbugs.gnu.org; 4 Sep 2021 21:47:50 +0000 Received: from localhost ([127.0.0.1]:48817 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMdVu-0004s0-9W for submit@debbugs.gnu.org; Sat, 04 Sep 2021 17:47:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48652) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMdVs-0004rn-05 for 50384@debbugs.gnu.org; Sat, 04 Sep 2021 17:47:48 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:46162) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMdVl-00083Z-NY; Sat, 04 Sep 2021 17:47:41 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=48866 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMdVl-0001xp-Eo; Sat, 04 Sep 2021 17:47:41 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <8900fa8c8eef7f72fc97adc2408be26c88de7803.camel@telenet.be> Date: Sat, 04 Sep 2021 23:47:39 +0200 In-Reply-To: <8900fa8c8eef7f72fc97adc2408be26c88de7803.camel@telenet.be> (Maxime Devos's message of "Sat, 04 Sep 2021 23:17:10 +0200") Message-ID: <877dfwypvo.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=1630792862; 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=UgOLJDsZm1Jn9+xWd0UYvHf7A7AgePj8s3HaOFNEt+s=; b=leStF4JQiMIM/RYGXTSEQmyZqs7jYuvp8mPKH1dvRbHIJ8BpT4QiDkNVgmxFXs+oAv1flh D0IVUp0eViWYpl+juSoMWPUGv0ENfHNo+4KNdb0pttM2EaN3HQLi4H3rwX5rlX1f4xp4+g DN5w1UJ5mak6ZvUr+j9E/dXzQosI2FDVYFlYcECGVd+Yp831MI3XML2pFlJ2mgtrFL1IsP hKHvsJZr9BlSaQM+/pEv5YWCTU6e4ez9+cIhS0PtTCRR4a74ZDYHoOP83N+UKglOLCPOXk eAzfCDTQbJkvGxRyEU3SefJKFThn+DOaEIDH+etB0RdsRVPHOQkISYPDmj3XOw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630792862; a=rsa-sha256; cv=none; b=IoxalEq31RT9Ma46TzQFKbG/+fcXnxC9P1kCyOxC0kety+bqNLY9FhGZn2nGaBgSssGG8u MBWrRTSv+Eh24aLVX3eoPFHvkKuE3jvDFwzn70Q7Gh+4tXdNipP13UcGgOm68YbnLLFdkB +YoPWZrohn+OdD6cTDKMzmPEA6LhSzVp3vgiCD+s9391l5UT70tBnjdFYgpF3bQTDZX6cZ rWsq+dv7/72wvXJKEK3a+h3ECaUJFYja3Ak7tLO2PNUbojR4g0frQM6wP/7HJoZpeEzXE6 u1sFOzSnPlcq3WAyQZAhvqiIwxu/pPGQ2rroTlghwD0FsE2SHpeTw/uFHn95qQ== 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: -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: 0EBA2149B0 X-Spam-Score: -1.42 X-Migadu-Scanner: scn0.migadu.com X-TUID: HX+Xs3p8ffi5 Hi! Some initial comments=E2=80=A6 Maxime Devos skribis: > +++ b/guix/gexp.scm > @@ -531,13 +531,37 @@ appears." > (define-gexp-compiler (local-file-compiler (file ) system ta= rget) > ;; "Compile" FILE by adding it to the store. > (match file > - (($ file (=3D force absolute) name sha256 recursive? se= lect?) > - ;; Canonicalize FILE so that if it's a symlink, it is resolved. Fa= iling > - ;; to do that, when RECURSIVE? is #t, we could end up creating a da= ngling > - ;; symlink in the store, and when RECURSIVE? is #f 'add-to-store' w= ould > - ;; just throw an error, both of which are inconvenient. > - (interned-file absolute name > - #:recursive? recursive? #:select? select?)))) > + ;; Delay computing the absolute file name until 'intern', as this > + ;; might be a relatively expensive computation (e.g. if search-patch > + ;; is used), especially on a spinning disk. > + (($ file absolute-promise name sha256 recursive? select= ?) > + (let () > + (define (intern) > + ;; Canonicalize FILE so that if it's a symlink, it is resolved. > + ;; Failing to do that, when RECURSIVE? is #t, we could end up c= reating > + ;; a dangling symlink in the store, and when RECURSIVE? is #f > + ;; 'add-to-store' would just throw an error, both of which are > + ;; inconvenient. > + (interned-file (force absolute-promise) name > + #:recursive? recursive? #:select? select?)) > + (if sha256 > + (let ((path (fixed-output-path name sha256 #:recursive? recur= sive?))) > + ;; If the hash is known in advance and the store already ha= s the > + ;; item, there is no need to intern the file. > + (if (file-exists? path) > + (mbegin %store-monad > + ;; Tell the GC that PATH will be used, such that it w= on't > + ;; be deleted. > + ((store-lift add-temp-root) path) > + ;; The GC could have deleted the item before add-temp= -root > + ;; completed, so check again if PATH exists. > + (if (file-exists? path) > + (return path) > + ;; If it has been removed, fall-back interning. > + (intern))) > + ;; If PATH does not yet exist, fall back to interning. > + (intern))) > + (intern)))))) =E2=80=98file-exists?=E2=80=99 won=E2=80=99t work when talking to a remote = store (e.g., GUIX_DAEMON_SOCKET=3Dssh://=E2=80=A6). =E2=80=98add-temp-root=E2=80=99 doesn=E2=80=99t throw if the given store it= em does not exist. So it could be written like this: (if sha256 (mbegin %store-monad (add-temp-root* item) (if (valid-path?* item) (return item) (intern))) (intern)) But then, we=E2=80=99d add one RPC for every =E2=80=98add-to-store=E2=80=99= RPC corresponding to a patch (you can set =E2=80=9CGUIX_PROFILING=3Drpc=E2=80=9D to see the numb= ers), which is not great. Ludo=E2=80=99.