Created
November 5, 2018 14:50
-
-
Save jadudm/b165190677bf3c3eab2c07c278d61808 to your computer and use it in GitHub Desktop.
Testing distributed places in Racket on a 256-core machine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
;; Place both files in the same directory, and launch with | |
;; racket -um stress-queen.rkt | |
(require racket/place) | |
(provide main) | |
(define worker-bee (make-parameter "stress-worker.rkt")) | |
(struct ptid (pid tid)) | |
(define (consumer N pch) | |
(let loop () | |
(printf "~a: ~a~n" N (place-channel-get pch)))) | |
(define (spawn N) | |
(let ([place (dynamic-place (worker-bee) 'main)]) | |
(define tid | |
(thread (λ () | |
(consumer N place)))) | |
(ptid place tid))) | |
(define (main) | |
(define ptids | |
(for/list ([n 100]) | |
(spawn n))) | |
(map (λ (pt) (place-wait (ptid-pid pt))) ptids)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require racket/place) | |
(provide main) | |
(define (main pch) | |
(define start (current-seconds)) | |
(define id (current-seconds)) | |
(let loop ([n 0]) | |
(when (< n 1000) | |
(place-channel-put pch n) | |
(loop (add1 n)))) | |
(printf "[~a] Worker done.~n" id) | |
;; Hang around for 3 minutes. | |
(let loop ([now (current-seconds)]) | |
(when (< (- start now) (* 60 3)) | |
(loop (current-seconds)))) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment