redex: parallelize benchmark generation modes
also, add a timeout (currently 5 mins)
This commit is contained in:
parent
e4ce0d0331
commit
3e83a816e2
|
@ -49,7 +49,10 @@
|
||||||
(compose (curry regexp-match #px"^.*([\\d]+)\\.rkt$") path->string)
|
(compose (curry regexp-match #px"^.*([\\d]+)\\.rkt$") path->string)
|
||||||
(directory-list (get-directory dir))))))))
|
(directory-list (get-directory dir))))))))
|
||||||
|
|
||||||
(define worklist files)
|
(struct work (file type))
|
||||||
|
|
||||||
|
(define worklist (for*/list ([f files] [t gen-types])
|
||||||
|
(work f t)))
|
||||||
|
|
||||||
(define work-sem (make-semaphore 1))
|
(define work-sem (make-semaphore 1))
|
||||||
|
|
||||||
|
@ -60,25 +63,36 @@
|
||||||
(semaphore-post work-sem)
|
(semaphore-post work-sem)
|
||||||
(void)]
|
(void)]
|
||||||
[else
|
[else
|
||||||
(define path (simplify-path (build-path here (car worklist))))
|
(match-define (work file type) (car worklist))
|
||||||
(set! worklist (cdr worklist))
|
(set! worklist (cdr worklist))
|
||||||
(semaphore-post work-sem)
|
(semaphore-post work-sem)
|
||||||
|
(define path (simplify-path (build-path here file)))
|
||||||
|
(define output-name (string-append (first
|
||||||
|
(regexp-split #rx"\\."
|
||||||
|
(last (regexp-split #rx"/" file))))
|
||||||
|
"-"
|
||||||
|
(symbol->string type)
|
||||||
|
"-results.rktd"))
|
||||||
(define args (apply string-append
|
(define args (apply string-append
|
||||||
(add-between (list* (if verbose? "-v" "")
|
(add-between (list (if verbose? "-v" "")
|
||||||
(string-append "-m " (number->string minutes))
|
(string-append "-m " (number->string minutes))
|
||||||
(map (λ (t)
|
(string-append "-o " output-name)
|
||||||
(string-append "-t "
|
(string-append "-t "
|
||||||
(symbol->string t)))
|
(symbol->string type)))
|
||||||
gen-types))
|
|
||||||
" ")))
|
" ")))
|
||||||
(system (let ([ans (apply string-append (add-between (list "racket" (path->string (build-path here "test-file.rkt"))
|
(define command (apply string-append
|
||||||
args (path->string path)) " "))])
|
(add-between (list "racket" (path->string (build-path here "test-file.rkt"))
|
||||||
(printf "~s\n" ans)
|
args (path->string path)) " ")))
|
||||||
ans))
|
(printf "running: ~s\n" command)
|
||||||
|
(system command)
|
||||||
(do-next)]))
|
(do-next)]))
|
||||||
|
|
||||||
(define (do-work)
|
(define (do-work)
|
||||||
(displayln worklist)
|
(printf "worklist:\n~a\n" (apply string-append
|
||||||
|
(add-between (for/list ([w (in-list worklist)])
|
||||||
|
(match-define (work f t) w)
|
||||||
|
(string-append f ": " (symbol->string t)))
|
||||||
|
", ")))
|
||||||
(for/list ([_ (in-range num-procs)])
|
(for/list ([_ (in-range num-procs)])
|
||||||
(thread do-next)))
|
(thread do-next)))
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,22 @@
|
||||||
(last (regexp-split #rx"/" filename))))
|
(last (regexp-split #rx"/" filename))))
|
||||||
"-results.rktd")))
|
"-results.rktd")))
|
||||||
|
|
||||||
|
(define (with-timeout time thunk fail-thunk)
|
||||||
|
(define res-chan (make-channel))
|
||||||
|
(define exn-chan (make-channel))
|
||||||
|
(define thd (thread (λ ()
|
||||||
|
(with-handlers ([exn:fail? (λ (exn) (channel-put exn-chan exn))])
|
||||||
|
(channel-put res-chan (thunk))))))
|
||||||
|
(sync
|
||||||
|
(handle-evt (alarm-evt (+ (current-inexact-milliseconds) time))
|
||||||
|
(λ (_)
|
||||||
|
(break-thread thd)
|
||||||
|
(fail-thunk)))
|
||||||
|
(handle-evt exn-chan
|
||||||
|
(λ (exn) (raise exn)))
|
||||||
|
(handle-evt res-chan
|
||||||
|
(λ (result-of-thunk) result-of-thunk))))
|
||||||
|
|
||||||
(define (run-generations fname verbose? no-errs? get-gen check seconds type)
|
(define (run-generations fname verbose? no-errs? get-gen check seconds type)
|
||||||
(collect-garbage)
|
(collect-garbage)
|
||||||
(define s-time (current-process-milliseconds))
|
(define s-time (current-process-milliseconds))
|
||||||
|
@ -74,9 +90,16 @@
|
||||||
(+ i terms) tot-time (exact->inexact (/ (+ i terms) (/ tot-time 1000)))))
|
(+ i terms) tot-time (exact->inexact (/ (+ i terms) (/ tot-time 1000)))))
|
||||||
(void)]
|
(void)]
|
||||||
[else
|
[else
|
||||||
(define term (g))
|
(define term (with-timeout (* 5 60 60) g
|
||||||
|
(λ () (printf "\nTimed out generating a test term in: ~a, ~a\n"
|
||||||
|
fname type)
|
||||||
|
(displayln i)
|
||||||
|
(loop (add1 i)))))
|
||||||
(define me-time (- (current-process-milliseconds) t-time))
|
(define me-time (- (current-process-milliseconds) t-time))
|
||||||
(define ok? (check term))
|
(define ok? (with-timeout (* 5 60 60) (λ () (check term))
|
||||||
|
(λ () (printf "\nIn ~a, ~a, timed out checking the term:~a\n"
|
||||||
|
fname type term)
|
||||||
|
(loop (add1 i)))))
|
||||||
(cond
|
(cond
|
||||||
[(not ok?)
|
[(not ok?)
|
||||||
(when verbose?
|
(when verbose?
|
||||||
|
|
Loading…
Reference in New Issue
Block a user