Index: rmt.scm ================================================================== --- rmt.scm +++ rmt.scm @@ -101,12 +101,11 @@ (file-exists? dbdir)) (tt:start-stats dbdir)) ;; fixme - find the right call to get the db directory ;; check the load on dbfname and add some delay using a droop curve of sorts (if *journal-stats* - (let* ((stats (tt:get-journal-stats)) - (load (or (alist-ref dbfname stats equal?) 0))) + (let* ((load (tt:get-journal-stats dbfname))) (if (> load 0) (let ((dely (* 10 load))) (debug:print 0 *default-log-port* "Journal load "load" delaying queries "dely"s.") (thread-sleep! dely))))) Index: runs.scm ================================================================== --- runs.scm +++ runs.scm @@ -1151,12 +1151,11 @@ ;; (runs:can-run-more-tests run-id jobgroup max-concurrent-jobs)) ;; look at the test jobgroup and tot jobs running (have-resources (and (if *journal-stats* (let* ((dbfname (conc (dbfile:run-id->dbnum run-id) ".db")) - (stats (tt:get-journal-stats)) - (load (or (alist-ref dbfname stats equal?) 0))) + (load (tt:get-journal-stats dbfname))) (if (> load 0.1) ;; dbs too busy to start more tests (begin (debug:print-info 0 *default-log-port* "Gating launch due to db load "load" based on journal file observations for "dbfname) #f) #t)) Index: tcp-transportmod.scm ================================================================== --- tcp-transportmod.scm +++ tcp-transportmod.scm @@ -1175,11 +1175,11 @@ ;; is it a journal file? (let ((parts (string-match "^(.*\\.db)-journal.*" fname))) (match parts ((_ dbfname) (hash-table-set! (jstats-jcount jstat) dbfname - (+ (hash-table-ref/default (jstats-jcount jstat) dbfname 0) 1) + (+ (hash-table-ref/default (jstats-jcount jstat) dbfname 0) 1.0) )) (else #f) ))) '() dbdir @@ -1201,11 +1201,11 @@ (thread-start! (make-thread (lambda ()(tt:journal-stats-run dbdir)) "Journal stats collection thread"))) -(define (tt:get-journal-stats) +(define (tt:get-journal-stats #!optional (dbfname #f)) (let* ((result (make-jstats)) (hitcounts (jstats-jcount result))) (if *journal-stats* (begin (mutex-lock! *journal-stats-mutex*) @@ -1224,16 +1224,19 @@ (+ hit-count (hash-table-ref/default hitcounts dbfname 0)))))))) (mutex-unlock! *journal-stats-mutex*)) (debug:print 0 *default-log-port* "INFO: *journal-stats* not set.")) ;; convert to normalized alist - (let ((tot (min (jstats-count result) 1)) ;; avoid divide by zero - (hits (jstats-jcount result))) ;; 1.db => count - (hash-table-map - hits - (lambda (fname hitcount) - (cons fname (/ hitcount tot))))))) + (let* ((tot (min (jstats-count result) 1)) ;; avoid divide by zero + (hits (jstats-jcount result)) ;; 1.db => count + (res (hash-table-map + hits + (lambda (fname hitcount) + (cons fname (/ hitcount tot)))))) + (if dbfname + (or (alist-ref dbfname res equal?) 0) + res)))) ;; megatest> (import tcp-transportmod) ;; megatest> (tt:write-load-tracking ".mtdb") ;; megatest> (hash-table-keys *journal-stats*) ;; (172060297)