[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gcmh 72683e1 13/32: Update conventions
From: |
Andrea Corallo |
Subject: |
[elpa] externals/gcmh 72683e1 13/32: Update conventions |
Date: |
Mon, 16 Nov 2020 17:32:05 -0500 (EST) |
branch: externals/gcmh
commit 72683e169beda961628bd00089625e0f26d16390
Author: Troy Hinckley <t.macman@gmail.com>
Commit: Troy Hinckley <t.macman@gmail.com>
Update conventions
First removed the unnecessary require statements. Then update some of
the wording to be clearer. Reworked the minor mode to be cleaner and
more consise. Split out the idle timer function to its own definition.
Also removed the setting of garbage-collection-messages. It may not be
desired behavior and does not disable with the minor mode. If the user
wants to set it, they can do so.
---
gcmh.el | 69 ++++++++++++++++++++++++++++-------------------------------------
1 file changed, 30 insertions(+), 39 deletions(-)
diff --git a/gcmh.el b/gcmh.el
index 40b70bf..d5762c0 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -34,37 +34,32 @@
;;; Code:
-(require 'custom)
-(require 'message)
-(require 'timer)
-(require 'easy-mmode)
-
(defcustom gcmh-low-cons-threshold 800000
- "High cons gc threshold.
-This is the gc threshold used while while idling. Default value is \
-the same of `gc-cons-threshold' default"
+ "Low cons gc threshold.
+This is the gc threshold used while while idling. Default value
+is the same of `gc-cons-threshold' default"
:group 'gcmh
:type 'number)
(defcustom gcmh-high-cons-threshold #x40000000
"High cons gc threshold.
-This should be set to a value that makes GC unlikely but does not make the OS \
-paging."
+This should be set to a value that makes GC unlikely but does not
+make the OS paging."
:group 'gcmh
:type 'number)
-(defcustom gcmh-time-constant 15
+(defcustom gcmh-idle-delay 15
"Idle time to wait in seconds before triggering GC."
:group 'gcmh
:type 'number)
(defcustom gcmh-verbose nil
- "If t print a message when garbage collecting."
+ "If t, print a message when garbage collecting."
:group 'gcmh
:type 'boolean)
-(defvar gcmh-timer nil
- "Idle timer set for trigering GC.")
+(defvar gcmh-idle-timer nil
+ "Idle timer for trigering GC.")
(defmacro gcmh-time (&rest body)
"Measure and return the time it takes to evaluate BODY."
@@ -77,35 +72,31 @@ paging."
This is to be used with the `pre-command-hook'."
(setq gc-cons-threshold gcmh-high-cons-threshold))
+(defun gcmh-idle-garbage-collect ()
+ "Run garbage collection after `gcmh-idle-delay'."
+ (if gcmh-verbose
+ (message "Garbage Collector ran for %.06f sec"
+ (gcmh-time (garbage-collect)))
+ (garbage-collect))
+ (setq gc-cons-threshold gcmh-low-cons-threshold))
+
;;;###autoload
(define-minor-mode gcmh-mode
- "Minor mode tweak Garbage Collection strategy."
+ "Minor mode to tweak Garbage Collection strategy."
:lighter " GCMH"
- :require 'gcmh
:global t
- (cond
- (gcmh-mode
- (progn
- (setq gc-cons-threshold gcmh-high-cons-threshold)
- ;; Print a message when garbage collecting
- (setq garbage-collection-messages gcmh-verbose)
- ;; When idle for 15sec run the GC no matter what.
- (unless gcmh-timer
- (setq gcmh-timer
- (run-with-idle-timer gcmh-time-constant t
- (lambda ()
- (if gcmh-verbose
- (message "Garbage Collector has run
for %.06fsec"
- (gcmh-time (garbage-collect)))
- (garbage-collect))
- (setq gc-cons-threshold
gcmh-low-cons-threshold)))))
- ;; Release severe GC strategy before the user restart to working
- (add-hook 'pre-command-hook #'gcmh-set-high-threshold)))
- (t (progn
- (setq gc-cons-threshold gcmh-low-cons-threshold)
- (cancel-timer gcmh-timer)
- (setq gcmh-timer nil)
- (remove-hook 'pre-command-hook #'gcmh-set-high-threshold)))))
+ (if gcmh-mode
+ (progn
+ (setq gc-cons-threshold gcmh-high-cons-threshold
+ ;; When idle for gcmh-idle-delay, run the GC no matter what.
+ gcmh-idle-timer (run-with-idle-timer gcmh-idle-delay t
+
#'gcmh-idle-garbage-collect))
+ ;; Release severe GC strategy before the user restart to working
+ (add-hook 'pre-command-hook #'gcmh-set-high-threshold))
+ (cancel-timer gcmh-idle-timer)
+ (setq gc-cons-threshold gcmh-low-cons-threshold
+ gcmh-idle-timer nil)
+ (remove-hook 'pre-command-hook #'gcmh-set-high-threshold)))
(provide 'gcmh)
- [elpa] externals/gcmh f542908 19/32: Merge branch 'feature/prevent-duplicate-timers' into 'master', (continued)
- [elpa] externals/gcmh f542908 19/32: Merge branch 'feature/prevent-duplicate-timers' into 'master', Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh f3389e9 26/32: Always use `setf' in place of `setq', Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 345121d 29/32: Readme update, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 81844fa 09/32: update readme, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh dd69c84 10/32: add warning into readme, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 537d050 18/32: Further minor typo, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 8867533 20/32: Improve messaging, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh f449abb 27/32: No reason anymore to use `run-with-idle-timer' so use `run-with-timer', Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 8bf0666 30/32: Rename `gcmh-register-idle-timer' into `gcmh-register-idle-gc', Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 12fd03c 24/32: Set the new timer for running once and on post-command-hook, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 72683e1 13/32: Update conventions,
Andrea Corallo <=
- [elpa] externals/gcmh b1bde50 22/32: Update copyright + email, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 9e241e0 21/32: Fix missing `gcmh-low-cons-threshold' set introduced by 8867533, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 84c43a4 23/32: Remove unnecessary require in README, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 855f03e 25/32: Implement auto idle delay mode, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 04e3c0c 28/32: Set `gcmh-auto-idle-delay-factor' to 20, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 2827dff 31/32: Clean-up unnecessary logic, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 5a83e25 32/32: Bump version 0.2, Andrea Corallo, 2020/11/16