Skip to content

Commit 148d049

Browse files
authored
Merge pull request #1369 from herbie-fp/job-forgetting
Add job forgetting to server
2 parents afeb0d1 + c432b16 commit 148d049

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/api/run.rkt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@
9696
[test-number (in-naturals)])
9797
(define result (job-wait job-id))
9898
(print-test-result (+ test-number 1) total-tests test result)
99-
(generate-bench-report result (test-name test) test-number dir total-tests)))
99+
(begin0 (generate-bench-report result (test-name test) test-number dir total-tests)
100+
(job-forget job-id))))
100101

101102
(define info (make-report-info results #:seed seed))
102103
(write-datafile (build-path dir "results.json") info)

src/api/server.rkt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
(provide job-path
2929
job-start
3030
job-status
31+
job-forget
3132
job-wait
3233
job-results
3334
job-timeline
@@ -154,6 +155,10 @@
154155
(log "Checking on: ~a.\n" job-id)
155156
(manager-ask 'check job-id))
156157

158+
(define (job-forget job-id)
159+
(log "Forgetting job: ~a.\n" job-id)
160+
(manager-ask 'forget job-id))
161+
157162
(define (job-wait job-id)
158163
(define finished-result (manager-ask 'wait manager job-id))
159164
(log "Done waiting for: ~a\n" job-id)
@@ -245,7 +250,10 @@
245250
[(list 'improve)
246251
(for/list ([(job-id result) (in-hash completed-jobs)]
247252
#:when (equal? (hash-ref result 'command) "improve"))
248-
result)]))
253+
result)]
254+
[(list 'forget job-id)
255+
(hash-remove! completed-jobs job-id)
256+
(void)]))
249257

250258
;; Implementation of threaded manager
251259

@@ -369,13 +377,17 @@
369377
(define total (+ (hash-count busy-workers) (hash-count queued-jobs)))
370378
(log "Currently ~a jobs total.\n" total)
371379
(place-channel-put handler total)]
372-
; Retreive the improve results for results.json
380+
; Retrieve the improve results for results.json
373381
[(list 'improve handler)
374382
(define improved-list
375383
(for/list ([(job-id result) (in-hash completed-jobs)]
376384
#:when (equal? (hash-ref result 'command) "improve"))
377385
result))
378-
(place-channel-put handler improved-list)]))))
386+
(place-channel-put handler improved-list)]
387+
; Forget a completed job result
388+
[(list 'forget handler job-id)
389+
(hash-remove! completed-jobs job-id)
390+
(place-channel-put handler (void))]))))
379391

380392
;; Implementation of threaded worker
381393

0 commit comments

Comments
 (0)