@@ -45,32 +45,41 @@ 36000)))) ;; 136000))) (debug:print 4 "INFO: dbpath=" dbpath) (sqlite3:set-busy-handler! db handler) (if (not dbexists) (db:initialize db)) - ;; (if (config-lookup *configdat* "setup" "synchronous") - ;; (begin - ;; (debug:print 5 "INFO: Turning off pragma synchronous") - ;; (sqlite3:execute db "PRAGMA synchronous = 0;")) - ;; (debug:print 5 "INFO: NOT turning off pragma synchronous")) + (if (equal? (config-lookup *configdat* "setup" "synchronous") "yes") + (begin + (debug:print 5 "INFO: Turning off pragma synchronous") + (sqlite3:execute db "PRAGMA synchronous = 0;")) + (debug:print 5 "INFO: NOT turning off pragma synchronous")) db)) (define (open-run-close proc idb . params) - (let* ((db (if idb idb (open-db))) - (res (apply proc db params))) + (let* ((db (if idb idb (open-db))) + (res #f)) + (if (equal? (config-lookup *configdat* "setup" "synchronous") "yes") + (sqlite3:execute db "PRAGMA synchronous = 0;")) + (set! res (apply proc db params)) (if (not idb)(sqlite3:finalize! db)) res)) (define *global-delta* 0) +(define *last-global-delta-printed* 0) (define (open-run-close-measure proc idb . params) (let* ((start-ms (current-milliseconds)) - (db (if idb idb (open-db))) - (res (apply proc db params))) + (db (if idb idb (open-db)))) + (if (equal? (config-lookup *configdat* "setup" "synchronous") "yes") + (sqlite3:execute db "PRAGMA synchronous = 0;")) + (set! res (apply proc db params)) (if (not idb)(sqlite3:finalize! db)) ;; scale by 10, average with current value. (set! *global-delta* (/ (+ *global-delta* (/ (- (current-milliseconds) start-ms) 200)) 2)) - (debug:print 4 "INFO: delta=" *global-delta*) + (if (> (abs (- *last-global-delta-printed* *global-delta*)) 0.08) ;; don't print all the time, only if it changes a bit + (begin + (debug:print 1 "INFO: launch throttle factor=" *global-delta*) + (set! *last-global-delta-printed* *global-delta*))) res)) (define (db:initialize db) (let* ((configdat (car *configinfo*)) ;; tut tut, global warning... (keys (config-get-fields configdat)) @@ -85,11 +94,11 @@ (begin (print "ERROR: your key cannot be named " keyn " as this conflicts with the same named field in the runs table") (system (conc "rm -f " dbpath)) (exit 1))))) keys) - ;; (sqlite3:execute db "PRAGMA synchronous = OFF;") + (sqlite3:execute db "PRAGMA synchronous = OFF;") (sqlite3:execute db "CREATE TABLE IF NOT EXISTS keys (id INTEGER PRIMARY KEY, fieldname TEXT, fieldtype TEXT, CONSTRAINT keyconstraint UNIQUE (fieldname));") (for-each (lambda (key) (sqlite3:execute db "INSERT INTO keys (fieldname,fieldtype) VALUES (?,?);" (key:get-fieldname key)(key:get-fieldtype key))) keys) (sqlite3:execute db (conc