Skip to content

Commit 2f289fa

Browse files
committed
Proof-of-concept parallelized fetching.
1 parent f87aefc commit 2f289fa

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

misc.lisp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@
177177
(flet ((action (stream)
178178
(call-with-skipping
179179
(lambda ()
180-
(map-sources (lambda (source)
181-
(force-output stream)
182-
(format t "~&Updating ~S from ~A~%"
183-
(project-name source)
184-
(location source))
185-
(update-source-cache source))))
180+
(pmap-sources (lambda (source)
181+
(force-output stream)
182+
(format t "~&Updating ~S from ~A~%"
183+
(project-name source)
184+
(location source))
185+
(update-source-cache source))))
186186
:stream stream)))
187187
(if file
188188
(with-open-file (stream file :direction :output

quicklisp-controller.asd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
#:cl-ppcre
1111
#:alexandria
1212
#:drakma
13-
#:ironclad)
13+
#:ironclad
14+
#:lparallel)
1415
:serial t
1516
:components ((:file "tarhash")
1617
(:file "package")

upstream.lisp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,24 @@
130130
(with-simple-restart (skip "Skip ~A source" project-name)
131131
(funcall fun (load-source-file project-name source-file)))))))
132132

133+
(defun pmap-sources (fun)
134+
(let ((dependency-tree (lparallel:make-ptree))
135+
(host-dependency (make-hash-table :test 'equal))
136+
(i 0))
137+
(map-sources (lambda (source)
138+
(let ((host (source-host source)))
139+
(lparallel:ptree-fn i (gethash host host-dependency)
140+
(lambda (&optional arg)
141+
(declare (ignore arg))
142+
(funcall fun source))
143+
dependency-tree)
144+
(setf (gethash host host-dependency) (list i))
145+
(incf i))))
146+
(lparallel:ptree-fn 'everything (loop for j below i collect j)
147+
(constantly nil) dependency-tree)
148+
(lparallel:call-ptree 'everything dependency-tree)
149+
nil))
150+
133151
(defun find-source (name)
134152
(block nil
135153
(map-sources (lambda (source)

0 commit comments

Comments
 (0)