#lang racket/base ;; Measurement of presence processing. ;; Peers observe each other, but do not process the resulting routing events. (require racket/match) (require prospect) (require logbook) (provide run) (struct presence (id) #:transparent) (define (run #:peer-count [peer-count 100]) (define routing-update-count 0) (define (peer id) (spawn (lambda (e count) (match e [(? patch? p) (set! routing-update-count (+ routing-update-count 1)) ;; (log-info "count for ~v is now ~v" id (+ count 1)) ;; (log-info "~a" (patch->pretty-string p)) (transition (+ count 1) '())] [_ #f])) 0 (patch-seq (pub (presence id)) (sub (advertise (presence ?)))))) (define boot-actions (for/list [(id (in-range peer-count))] (peer id))) (define-values (results cpu-time wall-clock-time gc-time) (time-apply (lambda () (run-ground boot-actions)) '())) (values routing-update-count (max 1 (- cpu-time gc-time)))) (module+ main (define E (standard-logbook-entry (default-logbook #:verbose? #t) "minimart" "observe-all-prospect")) (define T (logbook-table E "presence-processing" #:column-spec '(number-of-peers secs/routing-update routing-updates/sec secs/peer peers/sec routing-update-count run-duration-ms))) ;; Warmup (let () (run #:peer-count 1) (run #:peer-count 10) (void)) ;; Real run (for ((n (list* 1 2 5 (let loop ((n 10)) (if (>= n 500) '() (cons (inexact->exact (round n)) (loop (* n (sqrt (sqrt 2)))))))) )) (collect-garbage) (collect-garbage) (collect-garbage) (define-values (routing-update-count run-duration-ms) (run #:peer-count n)) (write-logbook-datum! T (list n (/ (/ run-duration-ms 1000.0) routing-update-count) (/ routing-update-count (/ run-duration-ms 1000.0)) (/ (/ run-duration-ms 1000.0) n) (/ n (/ run-duration-ms 1000.0)) routing-update-count run-duration-ms))))