1
0
mirror of https://github.com/m00natic/vlfi.git synced 2025-04-18 16:50:19 +01:00

Save times instead of speeds, compare on cumulative speed when tuning.

This commit is contained in:
Andrey Kotlarski 2014-09-04 03:33:05 +03:00
parent fb0503064d
commit 5379943cd7

View File

@ -107,7 +107,9 @@ VEC is a vector of (mean time . count) elements ordered by size."
(existing (aref ,vec idx))) (existing (aref ,vec idx)))
(aset ,vec idx (let ((count (1+ (cdr existing)))) ;recalculate mean (aset ,vec idx (let ((count (1+ (cdr existing)))) ;recalculate mean
(cons (/ (+ (* (1- count) (car existing)) (cons (/ (+ (* (1- count) (car existing))
(/ ,size ,time)) (/ (* ,time (1+ idx) ;aproximate time
vlf-tune-step) ;for this size
,size))
count) count)
count)))))) count))))))
@ -165,27 +167,29 @@ SIZE is number of bytes that are saved."
(defun vlf-tune-assess (type coef index) (defun vlf-tune-assess (type coef index)
"Get measurement value according to TYPE, COEF and INDEX." "Get measurement value according to TYPE, COEF and INDEX."
(* coef (cond ((eq type :insert) (* coef (cond ((eq type :insert)
(aref vlf-tune-insert-bps index)) (car (aref vlf-tune-insert-bps index)))
((eq type :raw) ((eq type :raw)
(aref vlf-tune-insert-raw-bps index)) (car (aref vlf-tune-insert-raw-bps index)))
((eq type :encode) ;encode size is less than batch size ((eq type :encode) ;encode size is less than batch size
(let ((val (aref vlf-tune-encode-bps index))) (let ((closest-idx index)
(while (and (null val) (< 0 index)) ;find smaller index (val (car (aref vlf-tune-encode-bps index))))
(setq index (1- index) (while (and (zerop val) (not (zerop closest-idx)))
val (aref vlf-tune-encode-bps index))) (setq closest-idx (1- closest-idx)
val)) val (car (aref vlf-tune-encode-bps
closest-idx))))
(/ (* val (1+ index)) (1+ closest-idx)))) ;approximate
((eq type :write) ((eq type :write)
(aref vlf-tune-write-bps index)) (car (aref vlf-tune-write-bps index)))
((eq type :hexl) ((eq type :hexl)
(aref vlf-tune-hexl-bps index)) (car (aref vlf-tune-hexl-bps index)))
((eq type :dehexlify) ((eq type :dehexlify)
(aref vlf-tune-dehexlify-bps index))))) (car (aref vlf-tune-dehexlify-bps index))))))
(defun vlf-tune-score (types index) (defun vlf-tune-score (types index)
"Get score of TYPES which is alist of (type coef) for INDEX." "Cumulative speed over TYPES which is alist of (type coef) for INDEX."
(catch 'result (catch 'result
(let ((score 0)) (let ((score 0))
(dolist (el types score) (dolist (el types (/ (* (1+ index) vlf-tune-step) score))
(let ((sc (if (consp el) (let ((sc (if (consp el)
(vlf-tune-assess (car el) (cadr el) index) (vlf-tune-assess (car el) (cadr el) index)
(vlf-tune-assess el 1 index)))) (vlf-tune-assess el 1 index))))
@ -231,7 +235,7 @@ INDEX if given, specifies search independent of current batch size."
vlf-tune-step)))))))))))) vlf-tune-step))))))))))))
(defun vlf-tune-best (types &optional min max) (defun vlf-tune-best (types &optional min max)
"Adjust `vlf-batch-size' to optional value. "Adjust `vlf-batch-size' to optional value with binary search.
Score is calculated over TYPES which is alist of form (type coef). Score is calculated over TYPES which is alist of form (type coef).
MIN and MAX may specify interval of indexes to search." MIN and MAX may specify interval of indexes to search."
(if (eq vlf-tune-enabled t) (if (eq vlf-tune-enabled t)
@ -243,11 +247,11 @@ MIN and MAX may specify interval of indexes to search."
vlf-tune-step)))) vlf-tune-step))))
(if (< (- max min) 3) (if (< (- max min) 3)
(vlf-tune-conservative types (round (+ min max) 2)) (vlf-tune-conservative types (round (+ min max) 2))
(let* ((right-idx (+ min (round (* 2 (- max min)) 3))) (let* ((right-idx (round (+ min (* 3 max)) 4))
(right (vlf-tune-score types right-idx))) (right (vlf-tune-score types right-idx)))
(if (null right) (if (null right)
(setq vlf-batch-size (* (1+ right-idx) vlf-tune-step)) (setq vlf-batch-size (* (1+ right-idx) vlf-tune-step))
(let* ((left-idx (+ min (round (- max min) 3))) (let* ((left-idx (round (+ (* 3 min) max) 4))
(left (vlf-tune-score types left-idx))) (left (vlf-tune-score types left-idx)))
(cond ((null left) (cond ((null left)
(setq vlf-batch-size (* (1+ left-idx) (setq vlf-batch-size (* (1+ left-idx)