profiles: Compute manual database entries in parallel.
This provides a 36% speedup on an SSD and 4 cores for the 1.5K man pages in the manual database derivation of: guix environment --ad-hoc jupyter python-ipython python-ipykernel * guix/profiles.scm (manual-database)[build]: Add 'print-string', 'print', and 'compute-entry'. Change 'compute-entries' to call 'compute-entry' in 'n-par-map'. Co-authored-by: Ludovic Courtès <ludo@gnu.org>master
parent
67cbfeae30
commit
ef4b5f2fed
|
@ -1418,26 +1418,38 @@ the entries in MANIFEST."
|
||||||
#~(begin
|
#~(begin
|
||||||
(use-modules (guix man-db)
|
(use-modules (guix man-db)
|
||||||
(guix build utils)
|
(guix build utils)
|
||||||
|
(ice-9 threads)
|
||||||
(srfi srfi-1)
|
(srfi srfi-1)
|
||||||
(srfi srfi-19))
|
(srfi srfi-19))
|
||||||
|
|
||||||
|
(define (print-string msg)
|
||||||
|
(display msg)
|
||||||
|
(force-output))
|
||||||
|
|
||||||
|
(define-syntax-rule (print fmt args ...)
|
||||||
|
;; Build up the string and display it at once.
|
||||||
|
(print-string (format #f fmt args ...)))
|
||||||
|
|
||||||
|
(define (compute-entry directory count total)
|
||||||
|
(print "\r[~3d/~3d] building list of man-db entries..."
|
||||||
|
count total)
|
||||||
|
(let ((man (string-append directory "/share/man")))
|
||||||
|
(if (directory-exists? man)
|
||||||
|
(mandb-entries man)
|
||||||
|
'())))
|
||||||
|
|
||||||
(define (compute-entries)
|
(define (compute-entries)
|
||||||
;; This is the most expensive part (I/O and CPU, due to
|
;; This is the most expensive part (I/O and CPU, due to
|
||||||
;; decompression), so report progress as we traverse INPUTS.
|
;; decompression), so report progress as we traverse INPUTS.
|
||||||
(let* ((inputs '#$(manifest-inputs manifest))
|
;; Cap at 4 threads because we don't see any speedup beyond that
|
||||||
(total (length inputs)))
|
;; on an SSD laptop.
|
||||||
(append-map (lambda (directory count)
|
(let* ((inputs '#$(manifest-inputs manifest))
|
||||||
(format #t "\r[~3d/~3d] building list of \
|
(total (length inputs))
|
||||||
man-db entries..."
|
(threads (min (parallel-job-count) 4)))
|
||||||
count total)
|
(concatenate
|
||||||
(force-output)
|
(n-par-map threads compute-entry inputs
|
||||||
(let ((man (string-append directory
|
(iota total 1)
|
||||||
"/share/man")))
|
(make-list total total)))))
|
||||||
(if (directory-exists? man)
|
|
||||||
(mandb-entries man)
|
|
||||||
'())))
|
|
||||||
inputs
|
|
||||||
(iota total 1))))
|
|
||||||
|
|
||||||
(define man-directory
|
(define man-directory
|
||||||
(string-append #$output "/share/man"))
|
(string-append #$output "/share/man"))
|
||||||
|
|
Reference in New Issue