Megatest

Check-in [ab4676a1d6]
Login
Overview
Comment:Tweaks to queuefeeder
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.60
Files: files | file ages | folders
SHA1: ab4676a1d6807e3fef734f553f1faacc8bbc3369
User & Date: mrwellan on 2015-06-23 07:23:24
Other Links: branch diff | manifest | tags
Context
2015-06-23
08:10
Got the tree working. Oops. Forgot that node0 was not dynamic (currently) check-in: cdcc055649 user: mrwellan tags: v1.60
07:23
Tweaks to queuefeeder check-in: ab4676a1d6 user: mrwellan tags: v1.60
00:50
Parts of tree showing for first time check-in: 19a493addb user: matt tags: v1.60
Changes

Modified loadwatch/queuefeeder-server.scm from [f479109577] to [4584852f4e].

63
64
65
66
67
68
69



70
71
72
73

74


75
76
77
78
79
80
81
   (else 
    (let ((res (* 50 (exp (- x targ)))))
      (cond
       ((and (> res 0)(< res 0.01)) 0.01)
       ((> res 45)                  45) ;; cap at 45 seconds
       (else res))))))




(define (piecewise-droop-calc x targ)
  (let ((top 50))
    (cond
     ((> (- x targ) 0) top) ;; top off at 45 seconds

     ((> x (- targ top))(+ (* 1 (- x (- targ top)))(/ (- top targ) targ)))


     (else (let ((res (/ x targ)))
	     (if (< res 0.01)
		 0.01
		 res))))))

(define (server soc)
  (print "server starting")







>
>
>



|
>
|
>
>







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
   (else 
    (let ((res (* 50 (exp (- x targ)))))
      (cond
       ((and (> res 0)(< res 0.01)) 0.01)
       ((> res 45)                  45) ;; cap at 45 seconds
       (else res))))))

;; x input value (current number in the queue)
;; targ is the desired queue length
;;
(define (piecewise-droop-calc x targ)
  (let ((top 50))
    (cond
     ((> (- x targ) 0)
      top) ;; top off at top seconds
     ((> x (- targ top))
      (+ (* 1 (- x (- targ top)))
	 (/ (- top targ) targ)))
     (else (let ((res (/ x targ)))
	     (if (< res 0.01)
		 0.01
		 res))))))

(define (server soc)
  (print "server starting")
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
(define *current-delay-mutex* (make-mutex))

;; update the *current-delay* value every minute or QUEUE_CHK_DELAY seconds
(thread-start! (make-thread (lambda ()
			      (let ((delay-time (string->number (or (get-environment-variable "QUEUE_CHK_DELAY") "30"))))
				(let loop ()
				  (with-input-from-pipe 
				   cmd
				   (lambda ()
				     (let* ((val       (read))
					    (droop-val (if (number? val)(piecewise-droop-calc val queuelen) #f)))
				       ;; val is number of jobs in queue. Use a linear droop of val/40
				       (mutex-lock! *current-delay-mutex*)
				       (set! *current-delay* (or droop-val 30)) ;; (/ (or droop-val 100) 50))
				       (mutex-unlock! *current-delay-mutex*)







|







158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
(define *current-delay-mutex* (make-mutex))

;; update the *current-delay* value every minute or QUEUE_CHK_DELAY seconds
(thread-start! (make-thread (lambda ()
			      (let ((delay-time (string->number (or (get-environment-variable "QUEUE_CHK_DELAY") "30"))))
				(let loop ()
				  (with-input-from-pipe 
				   cmd  ;;; my query to get queue length
				   (lambda ()
				     (let* ((val       (read))
					    (droop-val (if (number? val)(piecewise-droop-calc val queuelen) #f)))
				       ;; val is number of jobs in queue. Use a linear droop of val/40
				       (mutex-lock! *current-delay-mutex*)
				       (set! *current-delay* (or droop-val 30)) ;; (/ (or droop-val 100) 50))
				       (mutex-unlock! *current-delay-mutex*)

Modified loadwatch/queuefeeder.scm from [6ffa548735] to [b7ca858163].

76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

92
93
94
95


(let ((signature (make-signature)))
  
  (thread-start! (lambda ()
		   (thread-sleep! 60)
		   (print "Give up on waiting for the server")
		   (nn-close req)
		   ;; (exit)
		   ))
  (thread-join! (thread-start! (lambda ()
				 (let-values 
				  (((delay-time msg)(get-delay signature)))
				  (print "INFO: sleeping " delay-time " seconds per request of queuefeeder server")
				  (thread-sleep! delay-time)
				  (print "INFO: done waiting, now executing requested task."))))))


(process-execute (car cmd) (cdr cmd))









|







|
>




76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96


(let ((signature (make-signature)))
  
  (thread-start! (lambda ()
		   (thread-sleep! 60)
		   (print "Give up on waiting for the server")
		   ;; (nn-close req)
		   ;; (exit)
		   ))
  (thread-join! (thread-start! (lambda ()
				 (let-values 
				  (((delay-time msg)(get-delay signature)))
				  (print "INFO: sleeping " delay-time " seconds per request of queuefeeder server")
				  (thread-sleep! delay-time)
				  (print "INFO: done waiting, now executing requested task.")))))
  (nn-close req))

(process-execute (car cmd) (cdr cmd))