[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gcmh 1953d91 15/32: Merge branch 'master' into 'master'
From: |
Andrea Corallo |
Subject: |
[elpa] externals/gcmh 1953d91 15/32: Merge branch 'master' into 'master' |
Date: |
Mon, 16 Nov 2020 17:32:05 -0500 (EST) |
branch: externals/gcmh
commit 1953d913b5aa8822b83db8e20e17145470e01d79
Merge: c96bd70 5664cb3
Author: Koral <andrea_corallo@yahoo.it>
Commit: Koral <andrea_corallo@yahoo.it>
Merge branch 'master' into 'master'
Update conventions
See merge request koral/gcmh!1
---
gcmh.el | 70 +++++++++++++++++++++++++++++------------------------------------
1 file changed, 31 insertions(+), 39 deletions(-)
diff --git a/gcmh.el b/gcmh.el
index 40b70bf..d2eae63 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,32 @@ 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
+ (progn (message "Garbage collecting...")
+ (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] branch externals/gcmh created (now 5a83e25), Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh db9eceb 01/32: initial add, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 49db303 02/32: initial implementation, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 8008009 03/32: some minor fixes, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 920bc52 05/32: better comments, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 1953d91 15/32: Merge branch 'master' into 'master',
Andrea Corallo <=
- [elpa] externals/gcmh 5bf0ed3 16/32: Prevent duplicate idle timers being created, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh a7f8cc2 17/32: Correct minor typos, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 91cd1f7 07/32: autoload minor mode, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh e7af13d 11/32: better readme layout, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh c96bd70 12/32: update readme, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 5664cb3 14/32: Add garbage collection start message, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 75de01e 04/32: add missing requires, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh c1bc27a 06/32: Add readme, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh 65787bc 08/32: typo fix, Andrea Corallo, 2020/11/16
- [elpa] externals/gcmh f542908 19/32: Merge branch 'feature/prevent-duplicate-timers' into 'master', Andrea Corallo, 2020/11/16