(zilch magic): configurable CA build job count

Change-Id: I6a6a6964f157a33b35dae7245c344be7907c5221
This commit is contained in:
puck 2025-05-11 22:21:07 +00:00
parent dc7487b9e2
commit db3b2316f0
2 changed files with 12 additions and 8 deletions

View file

@ -38,12 +38,12 @@ to final build, or to specific Ninja targets.
; Set up the logger.
(define (set-print-logs val) #f)
(let ((prev-error-handler (current-exception-handler))) (current-exception-handler (lambda data (set-print-logs #t) (apply prev-error-handler data))))
(when (terminal-port? (current-error-port))
(let-values (((new-out new-err statusbar-set-print-logs logger) (statusbar-logger (current-output-port) (current-error-port) (assoc 'print-build-logs options))))
(current-output-port new-out)
(current-error-port new-err)
(set! set-print-logs statusbar-set-print-logs)
(*logger* logger)))
; (when (terminal-port? (current-error-port))
; (let-values (((new-out new-err statusbar-set-print-logs logger) (statusbar-logger (current-output-port) (current-error-port) (assoc 'print-build-logs options))))
; (current-output-port new-out)
; (current-error-port new-err)
; (set! set-print-logs statusbar-set-print-logs)
; (*logger* logger)))
;; Flags passed to the nix daemon:
(define max-jobs (if (assoc 'max-jobs options) (string->number (cdr (assoc 'max-jobs options))) (get-cpu-count)))
@ -52,6 +52,8 @@ to final build, or to specific Ninja targets.
(write-string (string-append "Connected to Nix daemon, version " (daemon-link-daemon-version (*daemon*)) "\n") (current-error-port))
(daemon-wop-set-options (*daemon*) verbosity max-jobs #t)
(ca-thread-count max-jobs)
(import
(scheme base) (scheme file) (scheme read)
(chicken format)

View file

@ -23,7 +23,7 @@
store-path-realised store-path-open
store-path-devirtualise
drv-resolve-ca
ca-thread-count drv-resolve-ca
zilch-magic-counters)
@ -333,6 +333,8 @@
(define-record-printer (<pending-item> item out)
(fprintf out "#<pending-item ~A - awaiting ~S>" (derivation-path (pending-item-ca-drv item)) (pending-item-awaiting-count item)))
(define ca-thread-count (make-parameter 4))
(define (rewrite-ca-stack input-drv)
; A mapping of CA derivation path to <pending-item>.
(define ca-to-pending-map (mapping (make-default-comparator)))
@ -478,7 +480,7 @@
(builder quit conn))))))
(define builder-threads '())
(do ((i 0 (+ i 1))) ((>= i 16) #f)
(do ((i 0 (+ i 1))) ((>= i (ca-thread-count)) #f)
(set! builder-threads
(cons
(thread-start!