[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf 06b4f85 262/310: Respect disabled tune settings and
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf 06b4f85 262/310: Respect disabled tune settings and move custom options. |
Date: |
Sat, 28 Nov 2020 00:33:28 -0500 (EST) |
branch: externals/vlf
commit 06b4f856ac34f9e9c93deabb5dff608b8eeadafc
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Respect disabled tune settings and move custom options.
---
vlf-base.el | 5 ----
vlf-tune.el | 92 ++++++++++++++++++++++++++++++++++++-------------------------
vlf.el | 5 +---
3 files changed, 56 insertions(+), 46 deletions(-)
diff --git a/vlf-base.el b/vlf-base.el
index 5b757c4..f568202 100644
--- a/vlf-base.el
+++ b/vlf-base.el
@@ -29,11 +29,6 @@
(require 'vlf-tune)
-(defcustom vlf-batch-size 1000000
- "Defines how large each batch of file data initially is (in bytes)."
- :group 'vlf :type 'integer)
-(put 'vlf-batch-size 'permanent-local t)
-
(defcustom vlf-before-chunk-update nil
"Hook that runs before chunk update."
:group 'vlf :type 'hook)
diff --git a/vlf-tune.el b/vlf-tune.el
index f9c0ca0..269c40a 100644
--- a/vlf-tune.el
+++ b/vlf-tune.el
@@ -23,11 +23,18 @@
;;; Commentary:
;; This package provides wrappers for basic chunk operations that add
-;; time statistics and automatic tuning of `vlf-batch-size' for
-;; optimal performance.
+;; profiling and automatic tuning of `vlf-batch-size'.
;;; Code:
+(defgroup vlf nil "View Large Files in Emacs."
+ :prefix "vlf-" :group 'files)
+
+(defcustom vlf-batch-size 1000000
+ "Defines how large each batch of file data initially is (in bytes)."
+ :group 'vlf :type 'integer)
+(put 'vlf-batch-size 'permanent-local t)
+
(defcustom vlf-tune-enabled t
"Whether to allow automatic change of batch size.
If nil, completely disable. If `stats', maintain measure statistics,
@@ -56,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 (round vlf-tune-max 1000)
+(defcustom vlf-tune-step (/ vlf-tune-max 1000)
"Step used for tuning in bytes."
:group 'vlf :type 'integer)
@@ -100,7 +107,7 @@ but don't change batch size. If t, measure and change."
(max 0 (1- (min (round size step) (round vlf-tune-max step))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; bookkeeping
+;;; profiling
(defun vlf-tune-initialize-measurement ()
"Initialize measurement vector."
@@ -125,9 +132,12 @@ VEC is a vector of (mean time . count) elements ordered by
size."
(defmacro vlf-time (&rest body)
"Get timing consed with result of BODY execution."
- `(let ((time (float-time))
- (result (progn ,@body)))
- (cons (- (float-time) time) result)))
+ `(if vlf-tune-enabled
+ (let* ((time (float-time))
+ (result (progn ,@body)))
+ (cons (- (float-time) time) result))
+ (let ((result (progn ,@body)))
+ (cons nil result))))
(defun vlf-tune-insert-file-contents (start end)
"Extract decoded file bytes START to END and save time it takes."
@@ -364,40 +374,48 @@ Suitable for multiple batch operations."
Best considered where primitive operations total is closest to
`vlf-tune-load-time'. If MIN-IDX and MAX-IDX are given,
confine search to this region."
- (or max-idx
- (setq max-idx (min max-idx (1- (/ (min vlf-tune-max
- (/ (1+ vlf-file-size) 2))
- vlf-tune-step)))))
- (let* ((idx (max 0 (or min-idx 0)))
- (best-idx idx)
- (best-time-diff vlf-tune-load-time)
- (all-less t)
- (all-more t))
- (while (and (not (zerop best-time-diff)) (< idx max-idx))
- (let ((time-diff (vlf-tune-score types idx t
- (+ vlf-tune-load-time
- best-time-diff))))
- (when time-diff
- (setq time-diff (if (< vlf-tune-load-time time-diff)
- (progn (setq all-less nil)
- (- time-diff vlf-tune-load-time))
- (setq all-more nil)
- (- vlf-tune-load-time time-diff)))
- (if (< time-diff best-time-diff)
- (setq best-idx idx
- best-time-diff time-diff))))
- (setq idx (1+ idx)))
- (* vlf-tune-step (1+ (cond ((eq all-less all-more) best-idx)
- (all-less max-idx)
- (t min-idx))))))
+ (if vlf-tune-enabled
+ (progn
+ (or max-idx
+ (setq max-idx (min max-idx
+ (1- (/ (min vlf-tune-max
+ (/ (1+ vlf-file-size) 2))
+ vlf-tune-step)))))
+ (let* ((idx (max 0 (or min-idx 0)))
+ (best-idx idx)
+ (best-time-diff vlf-tune-load-time)
+ (all-less t)
+ (all-more t))
+ (while (and (not (zerop best-time-diff)) (< idx max-idx))
+ (let ((time-diff (vlf-tune-score types idx t
+ (+ vlf-tune-load-time
+ best-time-diff))))
+ (when time-diff
+ (setq time-diff (if (< vlf-tune-load-time time-diff)
+ (progn (setq all-less nil)
+ (- time-diff
+ vlf-tune-load-time))
+ (setq all-more nil)
+ (- vlf-tune-load-time time-diff)))
+ (if (< time-diff best-time-diff)
+ (setq best-idx idx
+ best-time-diff time-diff))))
+ (setq idx (1+ idx)))
+ (* vlf-tune-step (1+ (cond ((or (zerop best-time-diff)
+ (eq all-less all-more))
+ best-idx)
+ (all-less max-idx)
+ (t min-idx))))))
+ vlf-batch-size))
(defun vlf-tune-load (types &optional region)
"Adjust `vlf-batch-size' slightly to better load time.
Optimize on TYPES on the nearby REGION. Use 2 if REGION is nil."
- (or region (setq region 2))
- (let ((idx (vlf-tune-closest-index vlf-batch-size)))
- (setq vlf-batch-size (vlf-tune-optimal-load types (- idx region)
- (+ idx 1 region)))))
+ (when (eq vlf-tune-enabled t)
+ (or region (setq region 2))
+ (let ((idx (vlf-tune-closest-index vlf-batch-size)))
+ (setq vlf-batch-size (vlf-tune-optimal-load types (- idx region)
+ (+ idx 1 region))))))
(provide 'vlf-tune)
diff --git a/vlf.el b/vlf.el
index feeb983..07554fa 100644
--- a/vlf.el
+++ b/vlf.el
@@ -39,8 +39,7 @@
;;; Code:
-(defgroup vlf nil "View Large Files in Emacs."
- :prefix "vlf-" :group 'files)
+(require 'vlf-base)
(defcustom vlf-before-batch-functions nil
"Hook that runs before multiple batch operations.
@@ -54,8 +53,6 @@ One argument is supplied that specifies current action.
Possible
values are: `write', `ediff', `occur', `search', `goto-line'."
:group 'vlf :type 'hook)
-(require 'vlf-base)
-
(autoload 'vlf-write "vlf-write" "Write current chunk to file." t)
(autoload 'vlf-re-search-forward "vlf-search"
"Search forward for REGEXP prefix COUNT number of times." t)
- [elpa] externals/vlf ffac697 217/310: Keep undo list after occur or unsuccessful line search., (continued)
- [elpa] externals/vlf ffac697 217/310: Keep undo list after occur or unsuccessful line search., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf b05255b 220/310: Add hooks to run around chunk moves and batch operations. Don't err, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 557d751 236/310: Be more precise on restoring hexl-mode after chunk update has been, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ece554a 231/310: Wording., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 069b2f5 240/310: Replace operations with respective vlf-tune wrappers., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf fb05030 241/310: Add basic tune strategies., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf e18a05b 247/310: Add linear search for tuning and prefer smaller batches., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 48a014f 250/310: Fix write measuring and endless loop in nearby approximation., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ee7409b 254/310: Tune batch size in more cases., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 5651ee3 252/310: Rename vlf-tune-optimal to vlf-tune-batch., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 06b4f85 262/310: Respect disabled tune settings and move custom options.,
Stefan Monnier <=
- [elpa] externals/vlf 199209f 263/310: Fix vlf-tune-optimal-load with no optional arguments supplied., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 023ee70 267/310: Declare hexl functions to please byte compiler., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf c3a308c 271/310: Optimize save performance over the temp file if such is used. Add, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ce13609 278/310: Fix vlf-ediff at the borders of hexl buffers., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf f43ada1 282/310: Fix byte compilation warnings., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 305d802 280/310: Use shared profiling info for encode, write and hexl operations., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 5dd9e2c 281/310: Adjust address parts of hexlified buffer according to vlf-start-pos., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 68d6c1b 289/310: vlf-occur changes:, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 0fa6248 288/310: Optimize unconditional chunk loading and prefer it in more cases of, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf bd5f9ca 286/310: Back to using per buffer profiling for encode speed., Stefan Monnier, 2020/11/28