1
0
mirror of https://github.com/m00natic/vlfi.git synced 2025-01-18 12:05:31 +00:00

Use shared profiling info for encode, write and hexl operations.

This commit is contained in:
Andrey Kotlarski 2014-10-08 19:33:59 +03:00
parent d579b7b3e2
commit 305d8022c4
2 changed files with 17 additions and 32 deletions

View File

@ -153,8 +153,6 @@ Prematurely ending indexing will still show what's found so far."
(batch-size vlf-batch-size) (batch-size vlf-batch-size)
(is-hexl (derived-mode-p 'hexl-mode)) (is-hexl (derived-mode-p 'hexl-mode))
(insert-bps vlf-tune-insert-bps) (insert-bps vlf-tune-insert-bps)
(encode-bps vlf-tune-encode-bps)
(hexl-bps vlf-tune-hexl-bps)
(insert-raw-bps vlf-tune-insert-raw-bps)) (insert-raw-bps vlf-tune-insert-raw-bps))
(with-temp-buffer (with-temp-buffer
(setq buffer-file-name file (setq buffer-file-name file
@ -164,11 +162,9 @@ Prematurely ending indexing will still show what's found so far."
(set-buffer-modified-p nil) (set-buffer-modified-p nil)
(set (make-local-variable 'vlf-batch-size) batch-size) (set (make-local-variable 'vlf-batch-size) batch-size)
(when vlf-tune-enabled (when vlf-tune-enabled
(setq vlf-tune-insert-bps insert-bps (setq vlf-tune-insert-bps insert-bps)
vlf-tune-encode-bps encode-bps)
(if is-hexl (if is-hexl
(progn (setq vlf-tune-hexl-bps hexl-bps (progn (setq vlf-tune-insert-raw-bps insert-raw-bps)
vlf-tune-insert-raw-bps insert-raw-bps)
(vlf-tune-batch '(:hexl :raw) t)) (vlf-tune-batch '(:hexl :raw) t))
(vlf-tune-batch '(:insert :encode) t))) (vlf-tune-batch '(:insert :encode) t)))
(vlf-mode 1) (vlf-mode 1)
@ -176,17 +172,13 @@ Prematurely ending indexing will still show what's found so far."
(goto-char (point-min)) (goto-char (point-min))
(vlf-build-occur regexp vlf-buffer) (vlf-build-occur regexp vlf-buffer)
(when vlf-tune-enabled (when vlf-tune-enabled
(setq insert-bps vlf-tune-insert-bps (setq insert-bps vlf-tune-insert-bps)
encode-bps vlf-tune-encode-bps)
(if is-hexl (if is-hexl
(setq hexl-bps vlf-tune-hexl-bps (setq insert-raw-bps vlf-tune-insert-raw-bps))))
insert-raw-bps vlf-tune-insert-raw-bps))))
(when vlf-tune-enabled ;merge back tune measurements (when vlf-tune-enabled ;merge back tune measurements
(setq vlf-tune-insert-bps insert-bps (setq vlf-tune-insert-bps insert-bps)
vlf-tune-encode-bps encode-bps)
(if is-hexl (if is-hexl
(setq vlf-tune-hexl-bps hexl-bps (setq vlf-tune-insert-raw-bps insert-raw-bps)))))
vlf-tune-insert-raw-bps insert-raw-bps)))))
(defun vlf-occur (regexp) (defun vlf-occur (regexp)
"Make whole file occur style index for REGEXP. "Make whole file occur style index for REGEXP.

View File

@ -60,11 +60,13 @@ but don't change batch size. If t, measure and change."
(if ram-size (if ram-size
(/ ram-size 20) (/ ram-size 20)
large-file-warning-threshold)) large-file-warning-threshold))
"Maximum batch size in bytes when auto tuning." "Maximum batch size in bytes when auto tuning.
Avoid increasing this after opening file with VLF."
:group 'vlf :type 'integer) :group 'vlf :type 'integer)
(defcustom vlf-tune-step (/ vlf-tune-max 10000) (defcustom vlf-tune-step (/ vlf-tune-max 10000)
"Step used for tuning in bytes." "Step used for tuning in bytes.
Avoid decreasing this after opening file with VLF."
:group 'vlf :type 'integer) :group 'vlf :type 'integer)
(defcustom vlf-tune-load-time 1.0 (defcustom vlf-tune-load-time 1.0
@ -83,23 +85,15 @@ but don't change batch size. If t, measure and change."
(defvar vlf-tune-encode-bps nil (defvar vlf-tune-encode-bps nil
"Vector of bytes per second encode measurements.") "Vector of bytes per second encode measurements.")
(make-variable-buffer-local 'vlf-tune-encode-bps)
(put 'vlf-tune-encode-bps 'permanent-local t)
(defvar vlf-tune-write-bps nil (defvar vlf-tune-write-bps nil
"Vector of bytes per second write measurements.") "Vector of bytes per second write measurements.")
(make-variable-buffer-local 'vlf-tune-write-bps)
(put 'vlf-tune-write-bps 'permanent-local t)
(defvar vlf-tune-hexl-bps nil (defvar vlf-tune-hexl-bps nil
"Vector of bytes per second hexlify measurements.") "Vector of bytes per second hexlify measurements.")
(make-variable-buffer-local 'vlf-tune-hexl-bps)
(put 'vlf-tune-hexl-bps 'permanent-local t)
(defvar vlf-tune-dehexlify-bps nil (defvar vlf-tune-dehexlify-bps nil
"Vector of bytes per second dehexlify measurements.") "Vector of bytes per second dehexlify measurements.")
(make-variable-buffer-local 'vlf-tune-dehexlify-bps)
(put 'vlf-tune-dehexlify-bps 'permanent-local t)
(defun vlf-tune-closest-index (size) (defun vlf-tune-closest-index (size)
"Get closest measurement index corresponding to SIZE." "Get closest measurement index corresponding to SIZE."
@ -114,8 +108,6 @@ but don't change batch size. If t, measure and change."
(defun vlf-tune-initialize-measurement () (defun vlf-tune-initialize-measurement ()
"Initialize measurement vector." "Initialize measurement vector."
(make-local-variable 'vlf-tune-max)
(make-local-variable 'vlf-tune-step)
(make-vector (1- (/ vlf-tune-max vlf-tune-step)) nil)) (make-vector (1- (/ vlf-tune-max vlf-tune-step)) nil))
(defmacro vlf-tune-add-measurement (vec size time) (defmacro vlf-tune-add-measurement (vec size time)
@ -168,15 +160,16 @@ FILE if given is filename to be used, otherwise `buffer-file-name'."
(cdr result) (car result)) (cdr result) (car result))
(cdr result))) (cdr result)))
(defun vlf-tune-write (start end append visit size &optional file) (defun vlf-tune-write (start end append visit size &optional file-name)
"Save buffer and save time it takes. "Save buffer and save time it takes.
START, END, APPEND, VISIT have same meaning as in `write-region'. START, END, APPEND, VISIT have same meaning as in `write-region'.
SIZE is number of bytes that are saved. SIZE is number of bytes that are saved.
FILE if given is filename to be used, otherwise `buffer-file-name'." FILE-NAME if given is to be used instead of `buffer-file-name'."
(let ((time (car (vlf-time (write-region start end (let* ((file (or file-name buffer-file-name))
(or file buffer-file-name) (time (car (vlf-time (write-region start end file append
append visit))))) visit)))))
(vlf-tune-add-measurement vlf-tune-write-bps size time))) (or (file-remote-p file) ;writing to remote files can include network copying
(vlf-tune-add-measurement vlf-tune-write-bps size time))))
(defun vlf-tune-hexlify () (defun vlf-tune-hexlify ()
"Activate `hexl-mode' and save time it takes." "Activate `hexl-mode' and save time it takes."