aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2024-11-08 19:01:54 +0000
committerChristopher Baines <mail@cbaines.net>2024-11-08 22:34:28 +0000
commitebeb4212ff279c10f601c98726c479b0a03a8469 (patch)
treefba19b2b36ecea0de7fb4bfe0ff60ab10c63d819
parentca5f0036f30fc833c70613b1a6f550bdf8d2d5a5 (diff)
downloaddata-service-ebeb4212ff279c10f601c98726c479b0a03a8469.tar
data-service-ebeb4212ff279c10f601c98726c479b0a03a8469.tar.gz
More efficiently create some vectors
And instrument the inferior memory after creating the gds-inferior-packages vector.
-rw-r--r--guix-data-service/jobs/load-new-guix-revision.scm39
1 files changed, 28 insertions, 11 deletions
diff --git a/guix-data-service/jobs/load-new-guix-revision.scm b/guix-data-service/jobs/load-new-guix-revision.scm
index 5f9e5b3..d3261a5 100644
--- a/guix-data-service/jobs/load-new-guix-revision.scm
+++ b/guix-data-service/jobs/load-new-guix-revision.scm
@@ -541,8 +541,13 @@
(/ (assoc-ref stats 'heap-size)
(expt 2. 20)))))
- (let ((vec (list->vector
- (iota ,count ,start-index))))
+ (let ((vec (make-vector ,count)))
+ (vector-fold
+ (lambda (i index _)
+ (vector-set! vec i index)
+ (1+ index))
+ ,start-index
+ vec)
(vector-map!
(lambda (_ index)
(define package (vector-ref gds-inferior-packages index))
@@ -736,18 +741,30 @@
(inferior-eval
`(define gds-inferior-packages
- (make-vector ,deduplicated-packages-length))
+ (vector ,@(map inferior-package-id deduplicated-packages)))
+ inf)
+ (inferior-eval
+ '(begin
+ (vector-map!
+ (lambda (_ id)
+ (or (hashv-ref %package-table id)
+ (error "missing package id")))
+ gds-inferior-packages)
+ #t)
inf)
(inferior-eval
- `(for-each
- (lambda (index id)
- (vector-set! gds-inferior-packages
- index
- (or (hashv-ref %package-table id)
- (error "missing package id"))))
- (iota ,deduplicated-packages-length)
- (list ,@(map inferior-package-id deduplicated-packages)))
+ '(let ((stats (gc-stats)))
+ (simple-format
+ (current-error-port)
+ "post gds-inferior-packages inferior heap: ~a MiB used (~a MiB heap)~%"
+ (round
+ (/ (- (assoc-ref stats 'heap-size)
+ (assoc-ref stats 'heap-free-size))
+ (expt 2. 20)))
+ (round
+ (/ (assoc-ref stats 'heap-size)
+ (expt 2. 20)))))
inf)
(values (list->vector deduplicated-packages)