* Increase gc-cons-threshold during package-init?
@ 2018-02-19 17:23 T.V Raman
2018-02-19 17:27 ` Daniel Colascione
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: T.V Raman @ 2018-02-19 17:23 UTC (permalink / raw)
To: emacs-devel
With Emacs now calling package-initialize on its own, I noticed (after
removing package-initialize from my emacs init file)
that emacs startup was now entailing 3 times as many gc calls during
startup as before. One guess is that my init file was lexically
binding gc-cons-threshold to 64MB --- the default gc-cons-threshold
of 800K is likely from the past and could be increased.
Even if we leave the default as is, it might make sense to temporarily
increase gc-cons-threshold within package-initialize
--
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Increase gc-cons-threshold during package-init?
2018-02-19 17:23 Increase gc-cons-threshold during package-init? T.V Raman
@ 2018-02-19 17:27 ` Daniel Colascione
2018-02-19 18:35 ` Eli Zaretskii
2018-02-19 21:15 ` Stefan Monnier
2018-02-20 17:27 ` Radon Rosborough
2 siblings, 1 reply; 6+ messages in thread
From: Daniel Colascione @ 2018-02-19 17:27 UTC (permalink / raw)
To: T.V Raman, emacs-devel
On 02/19/2018 09:23 AM, T.V Raman wrote:
> With Emacs now calling package-initialize on its own, I noticed (after
> removing package-initialize from my emacs init file)
> that emacs startup was now entailing 3 times as many gc calls during
> startup as before. One guess is that my init file was lexically
> binding gc-cons-threshold to 64MB --- the default gc-cons-threshold
> of 800K is likely from the past and could be increased.
There's a tradeoff though: increasing gc-cons-threshold means that the
GC that eventually occurs takes longer. I wish we had generational GC.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Increase gc-cons-threshold during package-init?
2018-02-19 17:23 Increase gc-cons-threshold during package-init? T.V Raman
2018-02-19 17:27 ` Daniel Colascione
@ 2018-02-19 21:15 ` Stefan Monnier
2018-02-20 0:49 ` T.V Raman
2018-02-20 17:27 ` Radon Rosborough
2 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2018-02-19 21:15 UTC (permalink / raw)
To: emacs-devel
> With Emacs now calling package-initialize on its own,
Not sure what you mean by "now": it's been the case since Emacs-24.1
(recent changes on `master` have only moved the time at which it takes
place).
> that emacs startup was now entailing 3 times as many gc calls during
> startup as before. One guess is that my init file was lexically
> binding gc-cons-threshold to 64MB ---
Lexically-binding it would have no effect on the GC, and since that var
is declared as dynamically scoped, it was probably dynamically bound.
Have you checked how much extra time is spent in the GC because of those
extra calls?
> the default gc-cons-threshold of 800K is likely from the past and
> could be increased.
This is a misunderstanding: the real gc-cons-threshold is computed
dynamically based on the heap size (see gc-cons-percentage).
Maybe those values need to be tweaked because tradeoffs have shifted
somewhat, but it doesn't seem very likely.
The problem with the above GC calls is much more fundamental and
unrelated to the actual values we choose: during periods of
initialization, programs typically allocate a lot of memory without
generating much garbage. So during those times running a GC tends to be
a waste of effort (we scan the whole heap only to find a few crumbs here
and there).
People often look at situations like yours and conclude that
gc-cons-threshold is too small. Yes, it's too small for those cases,
but bumping it once and forall makes things worse for the "usual" case,
leading to increased heap size, fragmentation, and longer pauses during
normal operation (tho this "usual case" is much more difficult to
measure).
There's no sadly way the GC can magically know that the last N megabytes
of allocation generated very little garbage, tho.
Maybe should bump those gc-knobs around the startup.el code (or maybe
more generally we should bump those knobs while loading a file).
> Even if we leave the default as is, it might make sense to temporarily
> increase gc-cons-threshold within package-initialize
Right. Tho doing this will likely cause a GC to happen right after
package-initialize, i.e. just before loading your ~/.emacs.
Better would be to bump it around both, I guess.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Increase gc-cons-threshold during package-init?
2018-02-19 21:15 ` Stefan Monnier
@ 2018-02-20 0:49 ` T.V Raman
0 siblings, 0 replies; 6+ messages in thread
From: T.V Raman @ 2018-02-20 0:49 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
By Now I meant "earlier that package-initialize was happening in my
startup file where the numbers were tweaked".
Agree to the rest of what you say -- the right thing might be to tweak
those during startup as a whole.>> With Emacs now calling package-initialize on its own,
>
> Not sure what you mean by "now": it's been the case since Emacs-24.1
> (recent changes on `master` have only moved the time at which it takes
> place).
>
>> that emacs startup was now entailing 3 times as many gc calls during
>> startup as before. One guess is that my init file was lexically
>> binding gc-cons-threshold to 64MB ---
>
> Lexically-binding it would have no effect on the GC, and since that var
> is declared as dynamically scoped, it was probably dynamically bound.
>
> Have you checked how much extra time is spent in the GC because of those
> extra calls?
>
>> the default gc-cons-threshold of 800K is likely from the past and
>> could be increased.
>
> This is a misunderstanding: the real gc-cons-threshold is computed
> dynamically based on the heap size (see gc-cons-percentage).
>
> Maybe those values need to be tweaked because tradeoffs have shifted
> somewhat, but it doesn't seem very likely.
>
> The problem with the above GC calls is much more fundamental and
> unrelated to the actual values we choose: during periods of
> initialization, programs typically allocate a lot of memory without
> generating much garbage. So during those times running a GC tends to be
> a waste of effort (we scan the whole heap only to find a few crumbs here
> and there).
>
> People often look at situations like yours and conclude that
> gc-cons-threshold is too small. Yes, it's too small for those cases,
> but bumping it once and forall makes things worse for the "usual" case,
> leading to increased heap size, fragmentation, and longer pauses during
> normal operation (tho this "usual case" is much more difficult to
> measure).
>
> There's no sadly way the GC can magically know that the last N megabytes
> of allocation generated very little garbage, tho.
>
> Maybe should bump those gc-knobs around the startup.el code (or maybe
> more generally we should bump those knobs while loading a file).
>
>> Even if we leave the default as is, it might make sense to temporarily
>> increase gc-cons-threshold within package-initialize
>
> Right. Tho doing this will likely cause a GC to happen right after
> package-initialize, i.e. just before loading your ~/.emacs.
> Better would be to bump it around both, I guess.
>
>
> Stefan
>
>
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Increase gc-cons-threshold during package-init?
2018-02-19 17:23 Increase gc-cons-threshold during package-init? T.V Raman
2018-02-19 17:27 ` Daniel Colascione
2018-02-19 21:15 ` Stefan Monnier
@ 2018-02-20 17:27 ` Radon Rosborough
2 siblings, 0 replies; 6+ messages in thread
From: Radon Rosborough @ 2018-02-20 17:27 UTC (permalink / raw)
To: T.V Raman; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 210 bytes --]
> With Emacs now calling package-initialize on its own
If you need to run (package-initialize) with special settings in your init
file,
just set `package-enable-at-startup' to nil in ~/.emacs.d/early-init.el.
[-- Attachment #2: Type: text/html, Size: 426 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-02-20 17:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-19 17:23 Increase gc-cons-threshold during package-init? T.V Raman
2018-02-19 17:27 ` Daniel Colascione
2018-02-19 18:35 ` Eli Zaretskii
2018-02-19 21:15 ` Stefan Monnier
2018-02-20 0:49 ` T.V Raman
2018-02-20 17:27 ` Radon Rosborough
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.