[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf d67825c 244/310: Move back to using average speed w
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf d67825c 244/310: Move back to using average speed when measuring and tuning. Be more |
Date: |
Sat, 28 Nov 2020 00:33:24 -0500 (EST) |
branch: externals/vlf
commit d67825c4cdd56f3ed9b713fd1116f63eca75289c
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Move back to using average speed when measuring and tuning. Be more
precise when choosing index for measurement.
---
vlf-tune.el | 59 ++++++++++++++++++++++++++++++-----------------------------
1 file changed, 30 insertions(+), 29 deletions(-)
diff --git a/vlf-tune.el b/vlf-tune.el
index 2c8f677..677e881 100644
--- a/vlf-tune.el
+++ b/vlf-tune.el
@@ -95,21 +95,19 @@ but don't change batch size. If t, measure and change."
(defun vlf-tune-closest-index (size)
"Get closest measurement index corresponding to SIZE."
- (max 0 (1- (min (round size vlf-tune-step)
- (/ vlf-tune-max vlf-tune-step)))))
+ (let ((step (float vlf-tune-step)))
+ (max 0 (1- (min (round size step) (round vlf-tune-max step))))))
(defmacro vlf-tune-add-measurement (vec size time)
"Add at an appropriate position in VEC new SIZE TIME measurement.
VEC is a vector of (mean time . count) elements ordered by size."
- `(when vlf-tune-enabled
+ `(when (and vlf-tune-enabled (not (zerop ,size)))
(or ,vec (setq ,vec (vlf-tune-initialize-measurement)))
(let* ((idx (vlf-tune-closest-index ,size))
(existing (aref ,vec idx)))
(aset ,vec idx (let ((count (1+ (cdr existing)))) ;recalculate mean
(cons (/ (+ (* (1- count) (car existing))
- (/ (* ,time (1+ idx) ;aproximate time
- vlf-tune-step) ;for this size
- ,size))
+ (/ ,size ,time))
count)
count))))))
@@ -188,14 +186,15 @@ SIZE is number of bytes that are saved."
(defun vlf-tune-score (types index)
"Cumulative speed over TYPES which is alist of (type coef) for INDEX."
(catch 'result
- (let ((score 0))
- (dolist (el types (/ (* (1+ index) vlf-tune-step) score))
- (let ((sc (if (consp el)
- (vlf-tune-assess (car el) (cadr el) index)
- (vlf-tune-assess el 1 index))))
- (if (zerop sc)
+ (let ((score 0)
+ (size (* (1+ index) vlf-tune-step)))
+ (dolist (el types (/ size score))
+ (let ((bps (if (consp el)
+ (vlf-tune-assess (car el) (cadr el) index)
+ (vlf-tune-assess el 1 index))))
+ (if (zerop bps)
(throw 'result nil)
- (setq score (+ score sc))))))))
+ (setq score (+ score (/ size bps)))))))))
(defun vlf-tune-conservative (types &optional index)
"Adjust `vlf-batch-size' with `vlf-tune-step' in case of better score.
@@ -245,22 +244,24 @@ MIN and MAX may specify interval of indexes to search."
max (or max (1- (/ (min vlf-tune-max
(/ vlf-file-size 2))
vlf-tune-step))))
- (if (< (- max min) 3)
- (vlf-tune-conservative types (round (+ min max) 2))
- (let* ((right-idx (round (+ min (* 3 max)) 4))
- (right (vlf-tune-score types right-idx)))
- (if (null right)
- (setq vlf-batch-size (* (1+ right-idx) vlf-tune-step))
- (let* ((left-idx (round (+ (* 3 min) max) 4))
- (left (vlf-tune-score types left-idx)))
- (cond ((null left)
- (setq vlf-batch-size (* (1+ left-idx)
- vlf-tune-step)))
- ((< right left)
- (vlf-tune-best types min
- (round (+ max min) 2)))
- (t (vlf-tune-best types (round (+ max min) 2)
- max))))))))))
+ (or (< max 1)
+ (if (< (- max min) 3)
+ (vlf-tune-conservative types (round (+ min max) 2))
+ (let* ((right-idx (round (+ min (* 3 max)) 4))
+ (right (vlf-tune-score types right-idx)))
+ (if (null right)
+ (setq vlf-batch-size (* (1+ right-idx)
+ vlf-tune-step))
+ (let* ((left-idx (round (+ (* 3 min) max) 4))
+ (left (vlf-tune-score types left-idx)))
+ (cond ((null left)
+ (setq vlf-batch-size (* (1+ left-idx)
+ vlf-tune-step)))
+ ((< right left)
+ (vlf-tune-best types min
+ (round (+ max min) 2)))
+ (t (vlf-tune-best types (round (+ max min) 2)
+ max)))))))))))
(provide 'vlf-tune)
- [elpa] externals/vlf db1da30 175/310: Use buffer-file-truename for file size determination and remove, (continued)
- [elpa] externals/vlf db1da30 175/310: Use buffer-file-truename for file size determination and remove, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 429a8ff 196/310: Widen region when measuring encoded content length., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf df8c9ea 191/310: Detect change of file when loading chunk and act more cautiously. Move, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf cc9b115 214/310: Update docstring for vlf-ediff-adjust., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 82fd5b9 203/310: Refine diff adjustment and in case of equality after it - make another, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 0199c24 218/310: Lower tramp verbosity level when dealing with multiple batches., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ee19f81 228/310: Load hexl advices after load and move vlf group definition., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 2c231df 226/310: Disable hexl-save-buffer and hexl revert when vlf-mode is active., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf a1ca1e3 232/310: Don't launch vlf when file size is less than vlf-batch-size., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf facdb9f 249/310: Fix binary tune base case and add approximation after access to, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf d67825c 244/310: Move back to using average speed when measuring and tuning. Be more,
Stefan Monnier <=
- [elpa] externals/vlf e3be8d5 079/310: Don't adjust chunk with more that 3 bytes and inhibit spurious update, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 1589cf9 081/310: Make custom revert function local only for vlfi buffers., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf b34bd2e 082/310: Don't use temporary buffer when adjusting expanded file content., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 681d3d9 084/310: Add vlfi-occur-mode., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 641ff4b 085/310: First feature complete version of vlfi-occur., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 1dcd122 086/310: Use overlays for number indicators., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf f14ef6c 087/310: Usability improvements to vlfi-occur., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 54927af 088/310: Update README and bump version., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf b8cc344 091/310: Add more detailed usage details., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf eaf85e5 093/310: Add key-binding to vlfi-mode-map in vlfi-edit-mode-map., Stefan Monnier, 2020/11/28