Compute lint warnings for packages in chunks

In an attempt to reduce the peak memory usage, and avoid running in to the:

  Too many heap sections: Increase MAXHINCR or MAX_HEAP_SECTS

issue.
This commit is contained in:
Christopher Baines 2022-09-05 08:40:27 +01:00
parent 1043b51bff
commit aa8c9dbffa

View file

@ -457,7 +457,7 @@ WHERE job_id = $1")
"vi_VN.UTF-8"
"zh_CN.UTF-8"))
(define (lint-warnings-for-checker checker-name)
(define (lint-warnings-for-checker packages checker-name)
`(lambda (store)
(let* ((checker (find (lambda (checker)
(eq? (lint-checker-name checker)
@ -590,25 +590,35 @@ WHERE job_id = $1")
'()
(with-time-logging (simple-format #f "getting ~A lint warnings"
name)
(format (current-error-port)
"inferior heap size: ~a MiB~%"
(round
(/ (inferior-eval '(assoc-ref (gc-stats) 'heap-size) inf)
(expt 2. 20))))
(let loop ((packages-chunks
(chunk packages 15000))
(warnings '()))
(let ((warnings
(inferior-eval-with-store
inf
store
(lint-warnings-for-checker name))))
(if (null? packages-chunks)
warnings
(let ((new-warnings
(inferior-eval-with-store
inf
store
(lint-warnings-for-checker (car packages-chunks) name))))
;; Clean the cached store connections, as there are caches
;; associated with these that take up lots of memory
(inferior-eval
'(when (defined? '%store-table) (hash-clear! %store-table))
inf)
;; Clean the cached store connections, as there are caches
;; associated with these that take up lots of memory
(inferior-eval
'(when (defined? '%store-table) (hash-clear! %store-table))
inf)
warnings))))))
(inferior-eval '(gc) inf)
(format (current-error-port)
"inferior heap size: ~a MiB~%"
(round
(/ (inferior-eval '(assoc-ref (gc-stats) 'heap-size) inf)
(expt 2. 20))))
(loop (cdr packages-chunks)
(append! warnings
new-warnings))))))))))
checkers))))
(define (all-inferior-package-derivations store inf packages)