1
0
mirror of https://github.com/m00natic/vlfi.git synced 2024-10-05 18:30:51 +01:00

Add function to linearly search best batch size according to existing

measurements and offer it when interactively changing batch size.
This commit is contained in:
Andrey Kotlarski 2014-09-07 00:08:32 +03:00
parent 35ede9403c
commit 9271f68c05
2 changed files with 21 additions and 1 deletions

View File

@ -345,6 +345,21 @@ Suitable for multiple batch operations."
(vlf-tune-conservative types (/ max-idx 2)) (vlf-tune-conservative types (/ max-idx 2))
(vlf-tune-binary types 0 max-idx))))))) (vlf-tune-binary types 0 max-idx)))))))
(defun vlf-tune-get-optimal (types)
"Get best batch size according to existing measurements over TYPES."
(let ((max-idx (1- (/ (min vlf-tune-max (/ (1+ vlf-file-size) 2))
vlf-tune-step)))
(best-idx 0)
(best-bps 0)
(idx 0))
(while (< idx max-idx)
(let ((bps (vlf-tune-score types idx t)))
(and bps (< best-bps bps)
(setq best-idx idx
best-bps bps)))
(setq idx (1+ idx)))
(* (1+ best-idx) vlf-tune-step)))
(provide 'vlf-tune) (provide 'vlf-tune)
;;; vlf-tune.el ends here ;;; vlf-tune.el ends here

7
vlf.el
View File

@ -259,7 +259,12 @@ with the prefix argument DECREASE it is halved."
(defun vlf-set-batch-size (size) (defun vlf-set-batch-size (size)
"Set batch to SIZE bytes and update chunk." "Set batch to SIZE bytes and update chunk."
(interactive (list (read-number "Size in bytes: " vlf-batch-size))) (interactive
(list (read-number "Size in bytes: "
(vlf-tune-get-optimal
(if (derived-mode-p 'hexl-mode)
'(:hexl :dehexlify :insert :encode)
'(:insert :encode))))))
(setq vlf-batch-size size) (setq vlf-batch-size size)
(vlf-move-to-batch vlf-start-pos)) (vlf-move-to-batch vlf-start-pos))