summaryrefslogtreecommitdiff
path: root/lisp/startup.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2019-06-26 10:03:48 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2019-06-26 10:03:48 -0400
commit698ff554ac2699ec48fefc85a1307cbc4a183b0d (patch)
treea7b7592f7973f81cad4410366d313e790616907e /lisp/startup.el
parent9233865b7005831e63755eb84ae7da060f878a55 (diff)
downloademacs-698ff554ac2699ec48fefc85a1307cbc4a183b0d.tar.gz
emacs-698ff554ac2699ec48fefc85a1307cbc4a183b0d.tar.bz2
emacs-698ff554ac2699ec48fefc85a1307cbc4a183b0d.zip
* lisp/calc/calc-ext.el (math-scalarp): Fix typo
Diffstat (limited to 'lisp/startup.el')
-rw-r--r--lisp/startup.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/lisp/startup.el b/lisp/startup.el
index 7759ed5aed3..2b4f4c7520c 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -980,6 +980,13 @@ XDG convention for dotfiles."
(found-path (if (file-exists-p xdg-path) xdg-path oldstyle-path)))
found-path))
+(defcustom gc-cons-opportunistic-idle-time 5
+ "Number of seconds before trying an opportunistic GC.
+After this number of seconds of idle time, Emacs tries to collect
+garbage more eagerly (i.e. with thresholds halved) in the hope
+to avoid running the GC later during non-idle time."
+ :type 'integer)
+
(defun command-line ()
"A subroutine of `normal-top-level'.
Amongst another things, it parses the command-line arguments."
@@ -1377,6 +1384,16 @@ please check its value")
(eq face-ignored-fonts old-face-ignored-fonts))
(clear-face-cache)))
+ ;; Start opportunistic GC (after loading the init file, so we obey
+ ;; its settings). This is desirable for two reason:
+ ;; - It reduces the number of times we have to GC in the middle of
+ ;; an operation.
+ ;; - It means we GC when the C stack is short, reducing the risk of false
+ ;; positives from the conservative stack scanning.
+ (when gc-cons-opportunistic-idle-time
+ (run-with-idle-timer gc-cons-opportunistic-idle-time t
+ #'garbage-collect-maybe 2))
+
(setq after-init-time (current-time))
;; Display any accumulated warnings after all functions in
;; `after-init-hook' like `desktop-read' have finalized possible