mirror of
				https://github.com/m00natic/vlfi.git
				synced 2025-11-04 00:51:37 +00:00 
			
		
		
		
	Rename vlf-tune-optimal to vlf-tune-batch.
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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))
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										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)
 | 
			
		||||
              (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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user