cbaines pushed a commit to branch master
in repository data-service.

commit c04ea067c2c0f226f304fe8e1c90a56c4fdf46f8
Author: Christopher Baines <[email protected]>
AuthorDate: Thu Oct 10 18:26:35 2024 +0100

    Make the WAL threshold more flexible
    
    So that the WAL can grow more when there's sufficient space. When the
    inferiors are closed it takes time to restart them, so doing this less 
should
    speed up processing revisions.
---
 guix-data-service/jobs/load-new-guix-revision.scm | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/guix-data-service/jobs/load-new-guix-revision.scm 
b/guix-data-service/jobs/load-new-guix-revision.scm
index 1412392..ddfd364 100644
--- a/guix-data-service/jobs/load-new-guix-revision.scm
+++ b/guix-data-service/jobs/load-new-guix-revision.scm
@@ -50,7 +50,7 @@
   #:use-module (guix serialization)
   #:use-module (guix build utils)
   #:use-module ((guix build syscalls)
-                #:select (set-thread-name))
+                #:select (set-thread-name free-disk-space))
   #:use-module (guix-data-service config)
   #:use-module (guix-data-service database)
   #:use-module (guix-data-service utils)
@@ -1761,14 +1761,19 @@ SELECT 1 FROM derivation_source_file_nars WHERE 
derivation_source_file_id = $1"
 
   (define (call-with-inferior proc)
     (define (check-wal-size)
-      (define threshold (* 4096 (expt 2 20)))
-
       (define (get-wal-bytes)
         (catch #t
           (lambda ()
             (stat:size (stat "/var/guix/db/db.sqlite-wal")))
           (lambda _ 0)))
 
+      (define threshold
+        (max
+         (* 4096 (expt 2 20))
+         (* 0.8
+            (- (free-disk-space "/var/guix/db/db.sqlite-wal")
+               (get-wal-bytes)))))
+
       (if (< (get-wal-bytes) threshold)
           #t
           (let loop ((wal-bytes (get-wal-bytes)))

Reply via email to