From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:48619) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfO03-0002wD-MG for guix-patches@gnu.org; Mon, 24 Jun 2019 08:23:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfO01-0001U7-Ra for guix-patches@gnu.org; Mon, 24 Jun 2019 08:23:07 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42185) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hfO00-0001P9-Bm for guix-patches@gnu.org; Mon, 24 Jun 2019 08:23:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hfO00-0003nf-6r for guix-patches@gnu.org; Mon, 24 Jun 2019 08:23:04 -0400 Subject: [bug#36351] [PATCH 06/10] derivations: 'derivation' preserves pointer equality. Resent-Message-ID: From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Mon, 24 Jun 2019 14:22:08 +0200 Message-Id: <20190624122212.5932-6-ludo@gnu.org> In-Reply-To: <20190624122212.5932-1-ludo@gnu.org> References: <20190624122212.5932-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 36351@debbugs.gnu.org * guix/derivations.scm (derivation): Check if FILE is already in %DERIVATION-CACHE and return it if it is. --- guix/derivations.scm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/guix/derivations.scm b/guix/derivations.scm index 5c568f223b..403e86749b 100644 --- a/guix/derivations.scm +++ b/guix/derivations.scm @@ -873,8 +873,12 @@ derivation. It is kept as-is, uninterpreted, in the derivation." (append (map derivation-input-path inputs) sources))) (drv* (set-field drv (derivation-file-name) file))) - (hash-set! %derivation-cache file drv*) - drv*))) + ;; Preserve pointer equality. This improves the performance of + ;; 'eq?'-memoization on derivations. + (or (hash-ref %derivation-cache file) + (begin + (hash-set! %derivation-cache file drv*) + drv*))))) (define (invalidate-derivation-caches!) "Invalidate internal derivation caches. This is mostly useful for -- 2.22.0