ein-utils: Make gc-cons-threshold adjustment optional.

EIN doesn't seem to always return gc-cons-threshold to its original value; this
makes for performance problems, particularly on Windows builds, so this behavior
is now optional and user-configurable.
This commit is contained in:
John Miller 2019-01-14 12:56:32 -06:00
parent 793d5fa192
commit 4c33a8b057

View file

@ -677,14 +677,21 @@ Use `ein:log' for debugging and logging."
`[,name ,callback :help ,(ein:get-docstring callback) ,@args]))
list-name-callback))
(defcustom ein:enable-gc-adjust t
"When t, EIN will set the `gc-cons-threshold' to an arbitrarily large value when opening notebookes. In some cases this adjustment will improve emacs performance, particularly when loading large notebooks."
:type 'boolean
:group 'ein)
(lexical-let ((current-gc-cons-threshold gc-cons-threshold))
(defun ein:gc-prepare-operation ()
(ein:log 'debug "[GC-PREPARE-OPERATION] Setting cons threshold to %s." (* current-gc-cons-threshold 10000) )
(setq gc-cons-threshold (* current-gc-cons-threshold 10000)))
(when ein:enable-gc-adjust
(setq gc-cons-threshold (* current-gc-cons-threshold 10000))))
(defun ein:gc-complete-operation ()
(ein:log 'debug "[GC-COMPLETE-OPERATION] Reverting cons threshold to %s." current-gc-cons-threshold)
(setq gc-cons-threshold current-gc-cons-threshold)))
(when ein:enable-gc-adjust
(setq gc-cons-threshold current-gc-cons-threshold))))
;;; Git utilities