mirror of
https://github.com/m00natic/vlfi.git
synced 2025-01-18 20:10:47 +00:00
Rename vlf-tune-optimal to vlf-tune-batch.
This commit is contained in:
parent
f3212ec9a6
commit
5651ee3d61
@ -257,7 +257,7 @@ Prematurely ending indexing will still show what's found so far."
|
|||||||
total-matches))))))))
|
total-matches))))))))
|
||||||
(setq end-of-file (= vlf-end-pos vlf-file-size))
|
(setq end-of-file (= vlf-end-pos vlf-file-size))
|
||||||
(unless end-of-file
|
(unless end-of-file
|
||||||
(vlf-tune-optimal tune-types)
|
(vlf-tune-batch tune-types)
|
||||||
(let ((batch-move (- vlf-end-pos batch-step)))
|
(let ((batch-move (- vlf-end-pos batch-step)))
|
||||||
(vlf-move-to-batch (if (or is-hexl
|
(vlf-move-to-batch (if (or is-hexl
|
||||||
(< match-end-pos
|
(< match-end-pos
|
||||||
|
@ -74,7 +74,7 @@ Use existing REPORTER and start TIME if given."
|
|||||||
(match-end 0)))))
|
(match-end 0)))))
|
||||||
((zerop vlf-start-pos)
|
((zerop vlf-start-pos)
|
||||||
(throw 'end-of-file nil))
|
(throw 'end-of-file nil))
|
||||||
(t (vlf-tune-optimal tune-types)
|
(t (vlf-tune-batch tune-types)
|
||||||
(let ((batch-move (- vlf-start-pos
|
(let ((batch-move (- vlf-start-pos
|
||||||
(- vlf-batch-size
|
(- vlf-batch-size
|
||||||
batch-step))))
|
batch-step))))
|
||||||
@ -107,7 +107,7 @@ Use existing REPORTER and start TIME if given."
|
|||||||
(match-end 0)))))
|
(match-end 0)))))
|
||||||
((= vlf-end-pos vlf-file-size)
|
((= vlf-end-pos vlf-file-size)
|
||||||
(throw 'end-of-file nil))
|
(throw 'end-of-file nil))
|
||||||
(t (vlf-tune-optimal tune-types)
|
(t (vlf-tune-batch tune-types)
|
||||||
(let ((batch-move (- vlf-end-pos batch-step)))
|
(let ((batch-move (- vlf-end-pos batch-step)))
|
||||||
(vlf-move-to-batch
|
(vlf-move-to-batch
|
||||||
(if (or is-hexl
|
(if (or is-hexl
|
||||||
@ -207,7 +207,7 @@ Search is performed chunk by chunk in `vlf-batch-size' memory."
|
|||||||
(time (float-time))
|
(time (float-time))
|
||||||
(success nil))
|
(success nil))
|
||||||
(font-lock-mode 0)
|
(font-lock-mode 0)
|
||||||
(vlf-tune-optimal '(:raw))
|
(vlf-tune-batch '(:raw))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(if (< 0 n)
|
(if (< 0 n)
|
||||||
(let ((start 0)
|
(let ((start 0)
|
||||||
@ -228,7 +228,7 @@ Search is performed chunk by chunk in `vlf-batch-size' memory."
|
|||||||
(while (re-search-forward "[\n\C-m]" nil t)
|
(while (re-search-forward "[\n\C-m]" nil t)
|
||||||
(setq n (1- n)))
|
(setq n (1- n)))
|
||||||
(vlf-verify-size)
|
(vlf-verify-size)
|
||||||
(vlf-tune-optimal '(:raw))
|
(vlf-tune-batch '(:raw))
|
||||||
(setq start end
|
(setq start end
|
||||||
end (min vlf-file-size
|
end (min vlf-file-size
|
||||||
(+ start vlf-batch-size)))
|
(+ start vlf-batch-size)))
|
||||||
@ -254,7 +254,7 @@ Search is performed chunk by chunk in `vlf-batch-size' memory."
|
|||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
(while (re-search-backward "[\n\C-m]" nil t)
|
(while (re-search-backward "[\n\C-m]" nil t)
|
||||||
(setq n (1- n)))
|
(setq n (1- n)))
|
||||||
(vlf-tune-optimal '(:raw))
|
(vlf-tune-batch '(:raw))
|
||||||
(setq end start
|
(setq end start
|
||||||
start (max 0 (- end vlf-batch-size)))
|
start (max 0 (- end vlf-batch-size)))
|
||||||
(progress-reporter-update reporter
|
(progress-reporter-update reporter
|
||||||
|
@ -311,12 +311,14 @@ optimizing over TYPES up to MAX-IDX."
|
|||||||
(or (not none-missing)
|
(or (not 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-optimal (types &optional linear)
|
(defun vlf-tune-batch (types &optional linear)
|
||||||
"Adjust `vlf-batch-size' to optimal value optimizing on TYPES.
|
"Adjust `vlf-batch-size' to optimal value optimizing on TYPES.
|
||||||
TYPES is alist of elements that may be of form (type coef) or
|
TYPES is alist of elements that may be of form (type coef) or
|
||||||
non list values in which case coeficient is assumed 1.
|
non list values in which case coeficient is assumed 1.
|
||||||
Types can be :insert, :raw, :encode, :write, :hexl or :dehexlify.
|
Types can be :insert, :raw, :encode, :write, :hexl or :dehexlify.
|
||||||
If LINEAR is non nil, use brute-force."
|
If LINEAR is non nil, use brute-force. In case requested measurement
|
||||||
|
is missing, stop search and set `vlf-batch-size' to this value.
|
||||||
|
Suitable for multiple batch operations."
|
||||||
(if (eq vlf-tune-enabled t)
|
(if (eq vlf-tune-enabled t)
|
||||||
(let ((max-idx (1- (/ (min vlf-tune-max
|
(let ((max-idx (1- (/ (min vlf-tune-max
|
||||||
(/ (1+ vlf-file-size) 2))
|
(/ (1+ vlf-file-size) 2))
|
||||||
|
10
vlf-write.el
10
vlf-write.el
@ -78,7 +78,7 @@ If changing size of chunk, shift remaining file content."
|
|||||||
(vlf-update-buffer-name)
|
(vlf-update-buffer-name)
|
||||||
(goto-char pos)))))
|
(goto-char pos)))))
|
||||||
(if hexl (vlf-tune-hexlify)))
|
(if hexl (vlf-tune-hexlify)))
|
||||||
(run-hook-with-args 'vlf-after-batch-functions 'write))
|
(run-hook-with-args 'vlf-after-batch-functions 'write))
|
||||||
t)
|
t)
|
||||||
|
|
||||||
(defun vlf-file-shift-back (size-change write-size)
|
(defun vlf-file-shift-back (size-change write-size)
|
||||||
@ -108,7 +108,7 @@ WRITE-SIZE is byte length of saved chunk."
|
|||||||
back at WRITE-POS. Return nil if EOF is reached, t otherwise."
|
back at WRITE-POS. Return nil if EOF is reached, t otherwise."
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
(vlf-verify-size t)
|
(vlf-verify-size t)
|
||||||
(vlf-tune-optimal '(:raw :write))
|
(vlf-tune-batch '(:raw :write))
|
||||||
(let ((read-end (min (+ read-pos vlf-batch-size) vlf-file-size)))
|
(let ((read-end (min (+ read-pos vlf-batch-size) vlf-file-size)))
|
||||||
(vlf-tune-insert-file-contents-literally read-pos read-end)
|
(vlf-tune-insert-file-contents-literally read-pos read-end)
|
||||||
(vlf-tune-write nil nil write-pos 0 (- read-end read-pos))
|
(vlf-tune-write nil nil write-pos 0 (- read-end read-pos))
|
||||||
@ -118,7 +118,7 @@ back at WRITE-POS. Return nil if EOF is reached, t otherwise."
|
|||||||
"Shift file contents SIZE-CHANGE bytes forward.
|
"Shift file contents SIZE-CHANGE bytes forward.
|
||||||
WRITE-SIZE is byte length of saved chunk.
|
WRITE-SIZE is byte length of saved chunk.
|
||||||
Done by saving content up front and then writing previous batch."
|
Done by saving content up front and then writing previous batch."
|
||||||
(vlf-tune-optimal '(:raw :write))
|
(vlf-tune-batch '(:raw :write))
|
||||||
(let ((read-size (max vlf-batch-size size-change))
|
(let ((read-size (max vlf-batch-size size-change))
|
||||||
(read-pos vlf-end-pos)
|
(read-pos vlf-end-pos)
|
||||||
(write-pos vlf-start-pos)
|
(write-pos vlf-start-pos)
|
||||||
@ -128,7 +128,7 @@ Done by saving content up front and then writing previous batch."
|
|||||||
(vlf-with-undo-disabled
|
(vlf-with-undo-disabled
|
||||||
(when (vlf-shift-batches read-size read-pos write-pos
|
(when (vlf-shift-batches read-size read-pos write-pos
|
||||||
write-size t)
|
write-size t)
|
||||||
(vlf-tune-optimal '(:raw :write))
|
(vlf-tune-batch '(:raw :write))
|
||||||
(setq write-pos (+ read-pos size-change)
|
(setq write-pos (+ read-pos size-change)
|
||||||
read-pos (+ read-pos read-size)
|
read-pos (+ read-pos read-size)
|
||||||
write-size read-size
|
write-size read-size
|
||||||
@ -137,7 +137,7 @@ Done by saving content up front and then writing previous batch."
|
|||||||
(let ((coding-system-for-write 'no-conversion))
|
(let ((coding-system-for-write 'no-conversion))
|
||||||
(while (vlf-shift-batches read-size read-pos write-pos
|
(while (vlf-shift-batches read-size read-pos write-pos
|
||||||
write-size nil)
|
write-size nil)
|
||||||
(vlf-tune-optimal '(:raw :write))
|
(vlf-tune-batch '(:raw :write))
|
||||||
(setq write-pos (+ read-pos size-change)
|
(setq write-pos (+ read-pos size-change)
|
||||||
read-pos (+ read-pos read-size)
|
read-pos (+ read-pos read-size)
|
||||||
write-size read-size
|
write-size read-size
|
||||||
|
Loading…
x
Reference in New Issue
Block a user