From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id oMPaKvByfmKsQQEAbAwnHQ (envelope-from ) for ; Fri, 13 May 2022 17:02:08 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id sFvjKfByfmKS3AAAG6o9tA (envelope-from ) for ; Fri, 13 May 2022 17:02:08 +0200 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 21F563DD52 for ; Fri, 13 May 2022 17:02:08 +0200 (CEST) Received: from localhost ([::1]:38838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npWnv-0000uO-1s for larch@yhetil.org; Fri, 13 May 2022 11:02:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npWnr-0000ty-43 for guix-patches@gnu.org; Fri, 13 May 2022 11:02:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50646) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1npWnq-0000xj-Qm for guix-patches@gnu.org; Fri, 13 May 2022 11:02:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1npWnq-0008B5-OO for guix-patches@gnu.org; Fri, 13 May 2022 11:02:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55398] [PATCH 3/3] store: Use a decaying cutoff in 'map/accumulate-builds'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 13 May 2022 15:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55398 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 55398@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 55398-submit@debbugs.gnu.org id=B55398.165245406831303 (code B ref 55398); Fri, 13 May 2022 15:02:02 +0000 Received: (at 55398) by debbugs.gnu.org; 13 May 2022 15:01:08 +0000 Received: from localhost ([127.0.0.1]:44533 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1npWmy-00088k-0D for submit@debbugs.gnu.org; Fri, 13 May 2022 11:01:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:41710) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1npWmu-00087j-E1 for 55398@debbugs.gnu.org; Fri, 13 May 2022 11:01:04 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:34264) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npWmp-0000rW-4j; Fri, 13 May 2022 11:00:59 -0400 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=t3Vx509AUNLNgKhLzt8Bx8yVwa6BPUi/NXUEHGYB8F0=; b=LlQTrEnqiaojAbcmMy54 9a73FDhuFCrSlPke5/hmqOo1sfgiBiDuCV6P56zpW5pOrCdOA5nfFzCIhTlSBlJxjQeT4HK49XKvn ZOyRRa9YbY226zij5+q7jqD2IOmdSPZ/lMGvJTwwxhybE0Aj8uMIINXOx1fCEpwfIa/VuTATQ3NY1 +DZrv68vWVAWbBWHbfHsVk6nTMe7+d0aFkhikwxzqbYWS/J6XA4LMDtoEsO+jecpMvKUeo/1ARtBK 5jrjUR+EgoQE6hFE77GthaELUsfNMECWZeunVKy6fICuxr3i5HGH7e5ygmieVrq1cAlXU3x4fP4/V 2LE8+CCMvpsV7Q==; Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=44956 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 1npWmo-0002Q4-O3; Fri, 13 May 2022 11:00:58 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Fri, 13 May 2022 17:00:44 +0200 Message-Id: <20220513150044.11991-3-ludo@gnu.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220513150044.11991-1-ludo@gnu.org> References: <20220513150044.11991-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: 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 X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1652454128; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=t3Vx509AUNLNgKhLzt8Bx8yVwa6BPUi/NXUEHGYB8F0=; b=HMkE4S1odh45t6gSr06K1zSgNdzWj3I2M4iy5wlMbGkUoZcjoLP5j/hSsgaxW/btNkJsQw sm2oUGOW6LE0rAbXIFGeuYj1xjBvAh8L6stWqIrodxpLHXl+mALfuzUPcbz53IICuD2kbj Z1orFraC4gSvL0fUZTrWDrEqLNmo3hx+b+ul7TeGK0EsDs/5MGmwCo0KaTwOQeVw1uToA1 wG3CTtjOu0ChwVzmPwGimH7DwMd0EfEZ+AUhbEgN8KQiXPShwCBiqJlKEJkOLPJOMkI0Tf y3JalBHIj6X9rCHLvGLHGNbIJti3mjMzzcvnY/IjfRdFtaOeOWTF/nVxb2n9oQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1652454128; a=rsa-sha256; cv=none; b=GpD8nf9nhi35THWAgLXWIiZToyN6y5qCRW3WL6nGR6JxDr63m9tWGzCd5W8qYtKAJdnZG5 t3g658GTLtpownveYa/brtL3Agn+uOqUvSzQyldZbieaeN4rVGsWCsj0NbSqvPZQYnsW/K WhsFKi0/xiFCSdN868/igcH6ZSZ4IK85Wiee2x41JXRTHPAKzFRRdB273RATUrjfp5BsLN sQUqnsbflOQmjQYO/Y2/CpeKErnNMoSu7RKkoahWphAH4GPJwOFdY1eKvVTg7aqaTquEtj u5q+YDYmiJtauKojQnkBplvq/abGRExK7u/67ijANA+FI95IgPiKdzIKIYVZPA== 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=LlQTrEnq; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.73 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=LlQTrEnq; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 21F563DD52 X-Spam-Score: -2.73 X-Migadu-Scanner: scn0.migadu.com X-TUID: GPf1JMHJ5giR This reduces the wall-clock time of: ./pre-inst-env guix system vm gnu/system/examples/desktop.tmpl -n from 2m13s to 53s (the timings depend on which derivations have already been built and are in store; in this case, many were missing). * guix/store.scm (default-cutoff): New variable. (map/accumulate-builds): Use it. Parameterize it in recursive calls to have decaying cutoff. --- guix/store.scm | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/guix/store.scm b/guix/store.scm index 220901f6ce..a3240eb2e0 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -1362,8 +1362,12 @@ (define (build-accumulator expected-store) (unresolved things continue) (continue #t)))) +(define default-cutoff + ;; Default cutoff parameter for 'map/accumulate-builds'. + (make-parameter 32)) + (define* (map/accumulate-builds store proc lst - #:key (cutoff 30)) + #:key (cutoff (default-cutoff))) "Apply PROC over each element of LST, accumulating 'build-things' calls and coalescing them into a single call. @@ -1377,21 +1381,24 @@ (define accumulator (build-accumulator store)) (define-values (result rest) - (let loop ((lst lst) - (result '()) - (unresolved 0)) - (match lst - ((head . tail) - (match (with-build-handler accumulator - (proc head)) - ((? unresolved? obj) - (if (>= unresolved cutoff) - (values (reverse (cons obj result)) tail) - (loop tail (cons obj result) (+ 1 unresolved)))) - (obj - (loop tail (cons obj result) unresolved)))) - (() - (values (reverse result) lst))))) + ;; Have the default cutoff decay as we go deeper in the call stack to + ;; avoid pessimal behavior. + (parameterize ((default-cutoff (quotient cutoff 2))) + (let loop ((lst lst) + (result '()) + (unresolved 0)) + (match lst + ((head . tail) + (match (with-build-handler accumulator + (proc head)) + ((? unresolved? obj) + (if (>= unresolved cutoff) + (values (reverse (cons obj result)) tail) + (loop tail (cons obj result) (+ 1 unresolved)))) + (obj + (loop tail (cons obj result) unresolved)))) + (() + (values (reverse result) lst)))))) (match (append-map (lambda (obj) (if (unresolved? obj) -- 2.36.0