From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iHoUIMFk8mHRyAAAgWs5BA (envelope-from ) for ; Thu, 27 Jan 2022 10:24:17 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id iB/NHMFk8mHKbwEAauVa8A (envelope-from ) for ; Thu, 27 Jan 2022 10:24:17 +0100 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 E6AD529D82 for ; Thu, 27 Jan 2022 10:24:16 +0100 (CET) Received: from localhost ([::1]:34784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nD10q-0004J1-54 for larch@yhetil.org; Thu, 27 Jan 2022 04:24:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nD0Sn-0008AT-Ha for bug-guix@gnu.org; Thu, 27 Jan 2022 03:49:08 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:33146) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nD0Sl-0000vh-7x for bug-guix@gnu.org; Thu, 27 Jan 2022 03:49:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nD0Sl-0007lt-6Y for bug-guix@gnu.org; Thu, 27 Jan 2022 03:49:03 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#48007: [PATCH 4/4] inferior: Move initialization bits away from 'inferior-eval-with-store'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Thu, 27 Jan 2022 08:49:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48007 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 48007@debbugs.gnu.org Received: via spool by 48007-submit@debbugs.gnu.org id=B48007.164327330929812 (code B ref 48007); Thu, 27 Jan 2022 08:49:03 +0000 Received: (at 48007) by debbugs.gnu.org; 27 Jan 2022 08:48:29 +0000 Received: from localhost ([127.0.0.1]:54278 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nD0SC-0007kk-FB for submit@debbugs.gnu.org; Thu, 27 Jan 2022 03:48:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33152) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nD0S5-0007jz-VG for 48007@debbugs.gnu.org; Thu, 27 Jan 2022 03:48:22 -0500 Received: from [2001:470:142:3::e] (port=51734 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nD0S0-0000sf-Mg; Thu, 27 Jan 2022 03:48:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=H2hIJv5PNG3OcMRCKci/Y9So9WR1BjpdxSjK7R02pQg=; b=S6exTHx28ESeS7INk2KU z6ns1UJV29FqZO49gdvVgFwNISjFsTO9n2uxqYYmbZReqBbBqyYt1ZUu/lc2AC4QangjkrGLqa2bR eexqMxG8SnZ2NCgluzFyeQpzAj4kkxLrBfpVTYfNH+3V3Vt1ouOD683KOKnkbkpImSm+3MegnxPYE GZWkPhpR2pZIOkJ79GXtLqiWXS5sFe9NecgJyEQo+ngE7+oc95VWNsyrw75wXslRIkmCVjG6mglHt FLyvRuq+9eTpvqQT9jHRjIHuIfX20TmONJ7sjBTsP14MAg25ZQo/61g5jNQ3sq1hIbyNnflbDRQX9 jzKu6ppRa0y1gg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:60148 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nD0S0-0002sQ-Ac; Thu, 27 Jan 2022 03:48:16 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Thu, 27 Jan 2022 09:47:43 +0100 Message-Id: <20220127084743.27130-4-ludo@gnu.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220127084743.27130-1-ludo@gnu.org> References: <87r18ufcft.fsf@gnu.org> <20220127084743.27130-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1643275457; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: 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=H2hIJv5PNG3OcMRCKci/Y9So9WR1BjpdxSjK7R02pQg=; b=srQmYf2NNVMZwgV+/DeJBMiBcnvVpVe68RQgMtjavR2QcVvzqc52QUSsLfvjTPniDCcWdY iLhbvePSbzaDdb8OZARsoEDF+45w/hpZHv5jAbPS8MKl2vEcbqSGZNgbpWpBvQbocRJCdf MF+8qBmn9f7x/R6qu94FpunxkeP/SYJTrViyfgytSNi8Mi158nk4rzTLIP/GcY4MFVPDsH KQgFgUX/TAY3XzYVHln6eBD+aZB5ot6og/dU8wYBCDgQgZFtCt0zEQ59BvMuD+2T4dzMWe xV7yRzbG1QND+WAyFtJERr2WpXULSarb695XXcEOo9ekWgfs0hSogUOSGBjpNg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1643275457; a=rsa-sha256; cv=none; b=iT66M3SefsTR9ARGffQd47upXCchKmSEjnI1pERLCKbXvob5GmtpaPq8ViSTqc/TnbEfGh ee0U5jWhk7KPMNe2va57hYNA85tzj6fn2dFW+v3rH+r1AnWuEefsIbOJks6xJRfj3vFm+H f7xe0tpkmoOHEXZEpbGxJRdzYRwHiF2r8HrNM3gBfw78xFjM4ehk2Us+uuYxDS8iPSNryX M+9iiQWCcr8PtDpMomNH0lkvUkVzF0cRudZWO/VNhOv8F8FoJxKEh1+8xLV711EqFqH+wP 81IkBNSiSRE2McRpvC7nX0cMlFBYxUF4fYiUkL/wYZ66/x9EYWKR/0o8tNN3Nw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=S6exTHx2; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.33 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=S6exTHx2; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: E6AD529D82 X-Spam-Score: -2.33 X-Migadu-Scanner: scn1.migadu.com X-TUID: WPd88aGsCAcg * guix/inferior.scm (port->inferior): In the inferior, define 'cached-store-connection', 'store-protocol-error?', and 'store-protocol-error-message'. (inferior-eval-with-store): Use them. --- guix/inferior.scm | 76 ++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/guix/inferior.scm b/guix/inferior.scm index 64dd1ce9b6..fc253dcc4f 100644 --- a/guix/inferior.scm +++ b/guix/inferior.scm @@ -225,7 +225,39 @@ (define* (port->inferior pipe #:optional (close close-port)) (inferior-eval '(use-modules (srfi srfi-34)) result) (inferior-eval '(define %package-table (make-hash-table)) result) - (inferior-eval '(define %store-table (make-hash-table)) + (inferior-eval '(begin + (define %store-table (make-hash-table)) + (define (cached-store-connection store-id version) + ;; Cache connections to store ID. This ensures that + ;; the caches within (in + ;; particular the object cache) are reused across + ;; calls to 'inferior-eval-with-store', which makes a + ;; significant different when it is called + ;; repeatedly. + (or (hashv-ref %store-table store-id) + + ;; 'port->connection' appeared in June 2018 and + ;; we can hardly emulate it on older versions. + ;; Thus fall back to 'open-connection', at the + ;; risk of talking to the wrong daemon or having + ;; our build result reclaimed (XXX). + (let ((store (if (defined? 'port->connection) + (port->connection %bridge-socket + #:version + version) + (open-connection)))) + (hashv-set! %store-table store-id store) + store)))) + result) + (inferior-eval '(begin + (define store-protocol-error? + (if (defined? 'store-protocol-error?) + store-protocol-error? + nix-protocol-error?)) + (define store-protocol-error-message + (if (defined? 'store-protocol-error-message) + store-protocol-error-message + nix-protocol-error-message))) result) result)) (_ @@ -627,39 +659,15 @@ (define (inferior-eval-with-store inferior store code) (store-id (object-address (store-connection-socket store)))) (ensure-store-bridge! inferior) (send-inferior-request - `(let ((proc ,code) - (error? (if (defined? 'store-protocol-error?) - store-protocol-error? - nix-protocol-error?)) - (error-message (if (defined? 'store-protocol-error-message) - store-protocol-error-message - nix-protocol-error-message))) - - ;; Cache connections to STORE-ID. This ensures that the caches within - ;; (in particular the object cache) are reused - ;; across calls to 'inferior-eval-with-store', which makes a - ;; significant different when it is called repeatedly. - (let ((store (or (hashv-ref %store-table ,store-id) - - ;; 'port->connection' appeared in June 2018 and we - ;; can hardly emulate it on older versions. Thus - ;; fall back to 'open-connection', at the risk of - ;; talking to the wrong daemon or having our build - ;; result reclaimed (XXX). - (let ((store (if (defined? 'port->connection) - (port->connection %bridge-socket - #:version ,proto) - (open-connection)))) - (hashv-set! %store-table ,store-id store) - store)))) - - ;; Serialize '&store-protocol-error' conditions. The - ;; exception serialization mechanism that - ;; 'read-repl-response' expects is unsuitable for SRFI-35 - ;; error conditions, hence this special case. - (guard (c ((error? c) - `(store-protocol-error ,(error-message c)))) - `(result ,(proc store))))) + `(let ((proc ,code) + (store (cached-store-connection ,store-id ,proto))) + ;; Serialize '&store-protocol-error' conditions. The exception + ;; serialization mechanism that 'read-repl-response' expects is + ;; unsuitable for SRFI-35 error conditions, hence this special case. + (guard (c ((store-protocol-error? c) + `(store-protocol-error + ,(store-protocol-error-message c)))) + `(result ,(proc store)))) inferior) (proxy inferior store) -- 2.34.0