From patchwork Fri Nov 11 21:57:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 44463 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A8FE027BBEA; Fri, 11 Nov 2022 21:58:31 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id CC6DE27BBE9 for ; Fri, 11 Nov 2022 21:58:30 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otc2G-0003um-GQ; Fri, 11 Nov 2022 16:58:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otc2E-0003uM-N5 for guix-patches@gnu.org; Fri, 11 Nov 2022 16:58:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otc2E-0000gx-Ec for guix-patches@gnu.org; Fri, 11 Nov 2022 16:58:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1otc2E-0003GE-BP for guix-patches@gnu.org; Fri, 11 Nov 2022 16:58:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#59078] [PATCH] lint: Split the derivation lint checker by system. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 11 Nov 2022 21:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59078 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Christopher Baines Cc: 59078@debbugs.gnu.org Received: via spool by 59078-submit@debbugs.gnu.org id=B59078.166820386812514 (code B ref 59078); Fri, 11 Nov 2022 21:58:02 +0000 Received: (at 59078) by debbugs.gnu.org; 11 Nov 2022 21:57:48 +0000 Received: from localhost ([127.0.0.1]:46914 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otc20-0003Fm-3G for submit@debbugs.gnu.org; Fri, 11 Nov 2022 16:57:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32934) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otc1x-0003FY-Mb for 59078@debbugs.gnu.org; Fri, 11 Nov 2022 16:57:46 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otc1s-0000f9-Fd; Fri, 11 Nov 2022 16:57:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=cuVrb0nyfLdB1+jaQibg2Rr8Wzu0A8bSFxThvMvT2nc=; b=BAFpAcm0760ubEHe91NV dvQN8JFS+pGM0LYBU6Nx1mqrd+zKiJdP4P+AWGJ5Wql78UCQt7W6SRdscROqhyiRtTi1HhL91bM0d FeSU6Cva/s9hUnHEYtC8G4I2QTl7kCT8xYyPQsX5piUl5ri9NYm9oBqXoyeVRFjNX678Hce7Upxs+ mtVvXbhm+Zb722mjqBpwIEXMYfg8DTNY58MicdPClTubqxMssGFcIQanWr5ea1o11CNiMGRRjZved XgC8KsDVRhAioyZzB0vXCsDVEQtrSBUIPeQDprBrhAwFtMiP4+8Mbtg1xv9u8UEc5xXMVuqK1wTpY PHxCCljAdHgG5g==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otc1q-0007vv-MM; Fri, 11 Nov 2022 16:57:40 -0500 From: Ludovic =?utf-8?q?Court=C3=A8s?= References: <20221106135532.5724-1-mail@cbaines.net> Date: Fri, 11 Nov 2022 22:57:36 +0100 In-Reply-To: <20221106135532.5724-1-mail@cbaines.net> (Christopher Baines's message of "Sun, 6 Nov 2022 14:55:32 +0100") Message-ID: <87k041dui7.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Hi, Christopher Baines skribis: > Currently, if you attempt to run the derivation checker on all packages, the > Guile process will run out of memory. I think a contributing factor to this is > that the checker forces an inefficient order when you want to generate > derivations for all the supported systems of each package, constantly > switching system then package. > > This problem also impacts the Guix Data Service, since it tries to run the > derivation checker for all packages. > > The changes in this commit to split the derivation lint checker in to several, > one for each system, means that you can now treat each system separately, > which should be better for caching purposes. > > If it's desirable to keep some notion of checking all supported systems for a > single package, I think lint checker groups could be added, so that you could > ask for the "derivation" checker, and this would run all the derivation > checkers. The ‘derivation’ checker was added for this purpose: making sure that a package’s derivation can be computed for all the supported systems. Previously it was easy to overlook that kind of breakage. I think it’s important to keep a ‘derivation’ checker that does this. Now, the memory consumption you report is unacceptable and this needs to be addressed. Most (all?) caches are now per-session (associated with ). Since ‘guix lint’ uses a single session, those caches keep growing because there’s no eviction mechanism in place. A hack like the one below should work around that. Could you check how well it works for you? It can also be helpful to set: GUIX_PROFILING=gc GUIX_PROFILING_EVENTS=after-gc Longer-term we should have a proper cache eviction mechanism in place. It’s not been a priority because “normal” applications such as ‘guix package’ don’t need it. Thanks, Ludo’. diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm index 9920c3ee62..6d9b9e96a9 100644 --- a/guix/scripts/lint.scm +++ b/guix/scripts/lint.scm @@ -209,23 +209,31 @@ (define (parse-options) (list-checkers-and-exit checkers)) (with-error-handling - (let ((any-lint-checker-requires-store? - (any lint-checker-requires-store? checkers))) + (let ((store-needed? (any lint-checker-requires-store? checkers))) - (define (call-maybe-with-store proc) - (if any-lint-checker-requires-store? - (with-store store - (proc store)) - (proc #f))) - - (call-maybe-with-store - (lambda (store) - (cond - ((null? args) - (fold-packages (lambda (p r) (run-checkers p checkers - #:store store)) '())) - (else - (for-each (lambda (package) - (run-checkers package checkers - #:store store)) - args))))))))) + (cond + ((null? args) + (let loop ((packages (fold-packages cons '())) + (processed 0) + (store #f)) + (match packages + ((package . rest) + (let ((store (and store-needed? + (if store + ;; XXX: Periodically start a new session + ;; with empty caches to avoid unbounded + ;; heap growth caused by the 'derivation' + ;; checker. + (if (zero? (modulo processed 1000)) + (begin + (close-connection store) + (open-connection)) + store) + (open-connection))))) + (run-checkers package checkers #:store store) + (loop rest (+ 1 processed) store)))))) + (else + (for-each (lambda (package) + (run-checkers package checkers + #:store store)) + args)))))))