From 5651ee3d61ab70697aea4b5a34aedafefc25acef Mon Sep 17 00:00:00 2001 From: Andrey Kotlarski Date: Sat, 6 Sep 2014 23:59:32 +0300 Subject: [PATCH] Rename vlf-tune-optimal to vlf-tune-batch. --- vlf-occur.el | 2 +- vlf-search.el | 10 +++++----- vlf-tune.el | 6 ++++-- vlf-write.el | 10 +++++----- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/vlf-occur.el b/vlf-occur.el index 809e42f..a867104 100644 --- a/vlf-occur.el +++ b/vlf-occur.el @@ -257,7 +257,7 @@ Prematurely ending indexing will still show what's found so far." total-matches)))))))) (setq end-of-file (= vlf-end-pos vlf-file-size)) (unless end-of-file - (vlf-tune-optimal tune-types) + (vlf-tune-batch tune-types) (let ((batch-move (- vlf-end-pos batch-step))) (vlf-move-to-batch (if (or is-hexl (< match-end-pos diff --git a/vlf-search.el b/vlf-search.el index 443276c..0c61898 100644 --- a/vlf-search.el +++ b/vlf-search.el @@ -74,7 +74,7 @@ Use existing REPORTER and start TIME if given." (match-end 0))))) ((zerop vlf-start-pos) (throw 'end-of-file nil)) - (t (vlf-tune-optimal tune-types) + (t (vlf-tune-batch tune-types) (let ((batch-move (- vlf-start-pos (- vlf-batch-size batch-step)))) @@ -107,7 +107,7 @@ Use existing REPORTER and start TIME if given." (match-end 0))))) ((= vlf-end-pos vlf-file-size) (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))) (vlf-move-to-batch (if (or is-hexl @@ -207,7 +207,7 @@ Search is performed chunk by chunk in `vlf-batch-size' memory." (time (float-time)) (success nil)) (font-lock-mode 0) - (vlf-tune-optimal '(:raw)) + (vlf-tune-batch '(:raw)) (unwind-protect (if (< 0 n) (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) (setq n (1- n))) (vlf-verify-size) - (vlf-tune-optimal '(:raw)) + (vlf-tune-batch '(:raw)) (setq start end end (min vlf-file-size (+ start vlf-batch-size))) @@ -254,7 +254,7 @@ Search is performed chunk by chunk in `vlf-batch-size' memory." (goto-char (point-max)) (while (re-search-backward "[\n\C-m]" nil t) (setq n (1- n))) - (vlf-tune-optimal '(:raw)) + (vlf-tune-batch '(:raw)) (setq end start start (max 0 (- end vlf-batch-size))) (progress-reporter-update reporter diff --git a/vlf-tune.el b/vlf-tune.el index f65521c..b3dd425 100644 --- a/vlf-tune.el +++ b/vlf-tune.el @@ -311,12 +311,14 @@ optimizing over TYPES up to MAX-IDX." (or (not none-missing) (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. TYPES is alist of elements that may be of form (type coef) or non list values in which case coeficient is assumed 1. 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) (let ((max-idx (1- (/ (min vlf-tune-max (/ (1+ vlf-file-size) 2)) diff --git a/vlf-write.el b/vlf-write.el index 5ef1d56..f15799a 100644 --- a/vlf-write.el +++ b/vlf-write.el @@ -78,7 +78,7 @@ If changing size of chunk, shift remaining file content." (vlf-update-buffer-name) (goto-char pos))))) (if hexl (vlf-tune-hexlify))) - (run-hook-with-args 'vlf-after-batch-functions 'write)) + (run-hook-with-args 'vlf-after-batch-functions 'write)) t) (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." (erase-buffer) (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))) (vlf-tune-insert-file-contents-literally read-pos read-end) (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. WRITE-SIZE is byte length of saved chunk. 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)) (read-pos vlf-end-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 (when (vlf-shift-batches read-size read-pos write-pos write-size t) - (vlf-tune-optimal '(:raw :write)) + (vlf-tune-batch '(:raw :write)) (setq write-pos (+ read-pos size-change) read-pos (+ read-pos 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)) (while (vlf-shift-batches read-size read-pos write-pos write-size nil) - (vlf-tune-optimal '(:raw :write)) + (vlf-tune-batch '(:raw :write)) (setq write-pos (+ read-pos size-change) read-pos (+ read-pos read-size) write-size read-size