mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 05:18:07 -05:00
size: Optimize dependency size computation.
This reduces 'guix size' run time by ~4% here: items="$(guix build icecat inkscape emacs libreoffice)" guix size $items * guix/scripts/size.scm (store-profile): Define 'size-table' and use it to lookup the size of ITEM in 'dependency-size'.
This commit is contained in:
parent
32c055fd32
commit
1199da08aa
1 changed files with 12 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
;;; GNU Guix --- Functional package management for GNU
|
||||
;;; Copyright © 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
|
||||
;;;
|
||||
;;; This file is part of GNU Guix.
|
||||
;;;
|
||||
|
@ -34,6 +34,7 @@ (define-module (guix scripts size)
|
|||
#:use-module (srfi srfi-37)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (ice-9 format)
|
||||
#:use-module (ice-9 vlist)
|
||||
#:export (profile?
|
||||
profile-file
|
||||
profile-self-size
|
||||
|
@ -142,11 +143,20 @@ (define (store-profile items)
|
|||
(lambda (size)
|
||||
(return (cons item size)))))
|
||||
refs)))
|
||||
(define size-table
|
||||
(fold (lambda (pair result)
|
||||
(match pair
|
||||
((item . size)
|
||||
(vhash-cons item size result))))
|
||||
vlist-null sizes))
|
||||
|
||||
(define (dependency-size item)
|
||||
(mlet %store-monad ((deps (requisites* (list item))))
|
||||
(foldm %store-monad
|
||||
(lambda (item total)
|
||||
(return (+ (assoc-ref sizes item) total)))
|
||||
(return (+ (match (vhash-assoc item size-table)
|
||||
((_ . size) size))
|
||||
total)))
|
||||
0
|
||||
(delete-duplicates (cons item deps)))))
|
||||
|
||||
|
|
Loading…
Reference in a new issue