1

Emacs startup time on Linux is 2.3 seconds. When I exit Emacs with C-xC-c, it quits instantly. This changes when I put only the following lines in my configuration:

(setq savehist-file (concat user-emacs-directory "savehist"))
(savehist-mode 1)

Then when starting Emacs, it took 4.5 seconds to start. That's nearly the double of the old startup time.

And when I quit Emacs, it tooks some time. I see only the message wrote /home/ReneFroger/Dropbox/Emacs/places before it finally quits.

I'm wondering which the savehist feature is consuming so much time? I didn't had this problem earlier.

ReneFroger
  • 3,855
  • 22
  • 63
  • 2
    How big is your `~/.emacs.d/history` file? (or whatever `savehist-file` is set to). Have you by any chance set `history-length` to be enormous? (compared to its default of 100). Or added some huge vars to `savehist-additional-variables`? In any case http://emacs.stackexchange.com/q/12086/454 might help. – phils Dec 09 '15 at 20:46
  • 1
    Let us know whether that's a duplicate? Failing that, does the performance improve if you move your config outside of the Dropbox directory? (I've heard of people having performance problems with Dropbox before.) – phils Dec 09 '15 at 20:57
  • I couldn't find any `~/.emacs.d/history` file. I assume you mean `/home/ReneFroger/Dropbox/Emacs/places`? If so, then it is 57 lines long. I have `(setq history-length 250)` in my init, the default is 30. No big deal, I assume. I don't understand why Dropbox would be related to this, because I haven't any performance problems, because my entire Emacs and my entire config are symlinked to my Dropbox folder. It occurs only when I put the lines above. – ReneFroger Dec 09 '15 at 22:17
  • If `/home/ReneFroger/Dropbox/Emacs/places` is the value of the `savehist-file` variable, then yes. That's an odd name for it, though. How large is the file? – phils Dec 09 '15 at 23:14
  • Oh, you're doing `(setq savehist-file (concat user-emacs-directory "savehist"))`, so that's the file you should be looking at. I've no idea what your `places` file is. – phils Dec 10 '15 at 00:40
  • 1
    This may be related: http://emacs.stackexchange.com/questions/4187/strip-text-properties-in-savehist. – PythonNut Dec 10 '15 at 23:06
  • @PythonNut It didn't help, but your answer is appreciated. – ReneFroger Dec 12 '15 at 21:54
  • @ReneFroger please do get back with the size of your `savehist` file. There's a good chance that has something to do with it. – PythonNut Dec 12 '15 at 21:55
  • @PythonNut what do you mean with do get back with the size of my `savehist`? – ReneFroger Dec 12 '15 at 21:56
  • @ReneFroger, what does `(nth 7 (file-attributes savehist-file))` say? – PythonNut Dec 12 '15 at 22:01
  • @PythonNut I get the message: `28622699 (#o155137553, #x1b4bf6b)` – ReneFroger Dec 12 '15 at 22:14
  • @ReneFroger 28.62MB. That's a big file. Please try to open the file, and see why it's so large. – PythonNut Dec 12 '15 at 22:15
  • 1
    @PythonNut, I see. I opened it, and I see Elisp all the way from my init.el configuration and some history. I decided to delete it and start again with brandnew `savehist`. Now it gets fast again. But I still not understand why it was related to writing `places`, but it's solved. PythonNut, you helped me again and I really appreciate your support! – ReneFroger Dec 12 '15 at 22:19
  • 1
    ReneFroger: A very large savehist file is *exactly* what my comments were about, which means that this is indeed a duplicate of the Q&A I linked to. Please look at the answer to that question to see how you might determine the exact culprit in that situation, and what you could do about it. – phils Dec 14 '15 at 20:59

1 Answers1

3

The problem you experienced is unrelated to the /home/ReneFroger/Dropbox/Emacs/places file.

Essentially, your savehist-file is becoming too large. Every time you close Emacs, it serializes the variables storing minibuffer histories along with any other variables of your choosing and writes it to the file. When you start Emacs, it does the reverse, reading the file, parsing it's contents, and reconstructing the state.

28,622,699 bytes is a lot of data. It may not sound like much, but serialization and parsing isn't a cheap operation, and therefore it takes a good bit of time to convert.

The temporary solution is to delete the savehist-file, but that only delays future bloat.

Usually, this is caused by some abnormal configuration. (history-length is too large, or too many variables are being saved, for example), and you'll need to investigate to determine why savehist is being directed to store all this data.

PythonNut
  • 10,243
  • 2
  • 29
  • 75
  • 1
    Readers should refer to [Abnormally large savehist file?](http://emacs.stackexchange.com/q/12086) (ideally *prior* to deleting their history file!), as well as [Strip text properties in savehist](http://emacs.stackexchange.com/q/4187). – phils Dec 14 '15 at 21:02