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.
This commit is contained in:
Christopher Baines 2024-10-10 18:26:35 +01:00
parent bb5b3731c8
commit c04ea067c2

View file

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