mirror of
https://github.com/m00natic/vlfi.git
synced 2025-01-18 03:55:31 +00:00
Change linear tune to search only known measures and use it to
initialize occur indexing. Make default tune step smaller.
This commit is contained in:
parent
3cfa9b1935
commit
61599a007f
10
vlf-occur.el
10
vlf-occur.el
@ -149,6 +149,7 @@ EVENT may hold details of the invocation."
|
||||
Prematurely ending indexing will still show what's found so far."
|
||||
(let ((vlf-buffer (current-buffer))
|
||||
(file buffer-file-name)
|
||||
(file-size vlf-file-size)
|
||||
(batch-size vlf-batch-size)
|
||||
(is-hexl (derived-mode-p 'hexl-mode))
|
||||
(insert-bps vlf-tune-insert-bps)
|
||||
@ -158,7 +159,8 @@ Prematurely ending indexing will still show what's found so far."
|
||||
(with-temp-buffer
|
||||
(setq buffer-file-name file
|
||||
buffer-file-truename file
|
||||
buffer-undo-list t)
|
||||
buffer-undo-list t
|
||||
vlf-file-size file-size)
|
||||
(set-buffer-modified-p nil)
|
||||
(set (make-local-variable 'vlf-batch-size) batch-size)
|
||||
(when vlf-tune-enabled
|
||||
@ -167,8 +169,8 @@ Prematurely ending indexing will still show what's found so far."
|
||||
(if is-hexl
|
||||
(progn (setq vlf-tune-hexl-bps hexl-bps
|
||||
vlf-tune-insert-raw-bps insert-raw-bps)
|
||||
(vlf-tune-batch '(:hexl :raw)))
|
||||
(vlf-tune-batch '(:insert :encode))))
|
||||
(vlf-tune-batch '(:hexl :raw) t))
|
||||
(vlf-tune-batch '(:insert :encode) t)))
|
||||
(vlf-mode 1)
|
||||
(if is-hexl (hexl-mode))
|
||||
(goto-char (point-min))
|
||||
@ -203,7 +205,7 @@ Prematurely ending indexing will still show what's found so far."
|
||||
(is-hexl (derived-mode-p 'hexl-mode)))
|
||||
(vlf-tune-batch (if (derived-mode-p 'hexl-mode)
|
||||
'(:hexl :raw)
|
||||
'(:insert :encode)))
|
||||
'(:insert :encode)) t)
|
||||
(vlf-with-undo-disabled
|
||||
(vlf-move-to-batch 0)
|
||||
(goto-char (point-min))
|
||||
|
22
vlf-tune.el
22
vlf-tune.el
@ -63,7 +63,7 @@ but don't change batch size. If t, measure and change."
|
||||
"Maximum batch size in bytes when auto tuning."
|
||||
:group 'vlf :type 'integer)
|
||||
|
||||
(defcustom vlf-tune-step (/ vlf-tune-max 1000)
|
||||
(defcustom vlf-tune-step (/ vlf-tune-max 10000)
|
||||
"Step used for tuning in bytes."
|
||||
:group 'vlf :type 'integer)
|
||||
|
||||
@ -339,22 +339,18 @@ MIN and MAX specify interval of indexes to search."
|
||||
(setq vlf-batch-size (* (1+ left-idx) vlf-tune-step)))))))
|
||||
|
||||
(defun vlf-tune-linear (types max-idx)
|
||||
"Adjust `vlf-batch-size' to optimal value using linear search,\
|
||||
optimizing over TYPES up to MAX-IDX."
|
||||
"Adjust `vlf-batch-size' to optimal known value using linear search.
|
||||
Optimize over TYPES up to MAX-IDX."
|
||||
(let ((best-idx 0)
|
||||
(best-bps 0)
|
||||
(idx 0)
|
||||
(none-missing t))
|
||||
(while (and none-missing (< idx max-idx))
|
||||
(idx 0))
|
||||
(while (< idx max-idx)
|
||||
(let ((bps (vlf-tune-score types idx)))
|
||||
(cond ((null bps)
|
||||
(setq vlf-batch-size (* (1+ idx) vlf-tune-step)
|
||||
none-missing nil))
|
||||
((< best-bps bps) (setq best-idx idx
|
||||
best-bps bps))))
|
||||
(and bps (< best-bps bps)
|
||||
(setq best-idx idx
|
||||
best-bps bps)))
|
||||
(setq idx (1+ idx)))
|
||||
(if none-missing
|
||||
(setq vlf-batch-size (* (1+ best-idx) vlf-tune-step)))))
|
||||
(setq vlf-batch-size (* (1+ best-idx) vlf-tune-step))))
|
||||
|
||||
(defun vlf-tune-batch (types &optional linear file)
|
||||
"Adjust `vlf-batch-size' to optimal value optimizing on TYPES.
|
||||
|
Loading…
Reference in New Issue
Block a user