all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Christopher Baines <mail@cbaines.net>
Cc: 59078@debbugs.gnu.org
Subject: [bug#59078] [PATCH] lint: Split the derivation lint checker by system.
Date: Fri, 11 Nov 2022 22:57:36 +0100	[thread overview]
Message-ID: <87k041dui7.fsf@gnu.org> (raw)
In-Reply-To: <20221106135532.5724-1-mail@cbaines.net> (Christopher Baines's message of "Sun, 6 Nov 2022 14:55:32 +0100")

[-- Attachment #1: Type: text/plain, Size: 1957 bytes --]

Hi,

Christopher Baines <mail@cbaines.net> 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
<store-connection>).  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’.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 2392 bytes --]

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)))))))

  parent reply	other threads:[~2022-11-11 21:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-06 13:55 [bug#59078] [PATCH] lint: Split the derivation lint checker by system Christopher Baines
2022-11-07 17:37 ` Christopher Baines
2022-11-11 21:57 ` Ludovic Courtès [this message]
2022-11-13 17:27   ` Christopher Baines
2022-11-14 12:51     ` Ludovic Courtès
2022-11-15  8:35       ` Christopher Baines
2022-11-17 17:22         ` Ludovic Courtès
2022-11-15  9:03       ` zimoun
2023-01-27 17:48         ` Simon Tournier
2023-01-31 16:33           ` Ludovic Courtès
2023-02-01  9:47             ` zimoun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k041dui7.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=59078@debbugs.gnu.org \
    --cc=mail@cbaines.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.