Skip to content

Commit fd6b936

Browse files
committed
Avoid duplicative re-computation of the same results
1 parent 1920a02 commit fd6b936

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/api/server.rkt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
(define manager #f)
102102

103103
(define (manager-ask msg . args)
104-
(log "Asking manager: ~a, ~a.\n" msg args)
104+
(log "Asking manager: ~a.\n" msg)
105105
(match manager
106106
[(? place? x) (apply manager-ask-threaded x msg args)]
107107
['basic (apply manager-ask-basic msg args)]))
@@ -122,22 +122,25 @@
122122
(define command (hash-ref queued-jobs job-id #f))
123123
(define result (and command (herbie-do-server-job command job-id)))
124124
(when command
125+
(hash-remove! queued-jobs job-id)
125126
(hash-set! completed-jobs job-id result))
126127
result]
127128
[(list 'result job-id) (hash-ref completed-jobs job-id #f)]
128129
[(list 'timeline job-id)
129130
(define command (hash-ref queued-jobs job-id #f))
130131
(define result (and command (herbie-do-server-job command job-id)))
131132
(when command
133+
(hash-remove! queued-jobs job-id)
132134
(hash-set! completed-jobs job-id result))
133135
result]
134136
[(list 'check job-id)
135137
(define command (hash-ref queued-jobs job-id #f))
136138
(define result (and command (herbie-do-server-job command job-id)))
137139
(when command
140+
(hash-remove! queued-jobs job-id)
138141
(hash-set! completed-jobs job-id result))
139142
job-id]
140-
[(list 'count) 0]
143+
[(list 'count) (hash-count queued-jobs)]
141144
[(list 'improve)
142145
(for/list ([(job-id result) (in-hash completed-jobs)]
143146
#:when (equal? (hash-ref result 'command) "improve"))

0 commit comments

Comments
 (0)