What can cause this problem? Is it caused by Emacs or it is due to my pc's performance? Generally what are the variables that affect Emacs' performance?
Emacs has around 50,000 internal variables and a few thousand external packages averaging at a few dozen variables each, you can't expect someone to answer this in a general sense. :-)
You can see that just by looking at the comments thread under your question. There are half a dozen different suggestions in there, all equally valid.
What can you do to pinpoint the problem?
Option 1: Disable modes
Start disabling those minor-modes you've listed, and see which one solves you performance issue. I would start with smartparens
, auto-complete
, line-number
and font-lock
, and then follow down the list.
"I didn't have this problem yesterday" means very little, don't rely on it too heavily. Just start disabling minor-modes until something solves it.
If none of the minor-modes fix your issue, then start commenting out portions of your init file until you find out which snippet was causing this. In any case, ask a new question when you have something more specific.
Option 2: The profiler
- Invoke
M-x profiler-start RET RET
(the second RET
is to confirm cpu
);
- Do some typing, preferably an entire paragraph or more;
- Invoke
M-x profiler-report
.
That will give you a buffer describing the cpu time taken by each function. Hitting TAB
on a line expands it to display the functions inside it.
Navigate this buffer until you find out which function is taking so much CPU time.
What do I do afterwards?
Once you find the function or package or snippet causing lag you can (in no particular order):
- Ask a new question here regarding that specific minor-mode (or function or snippet).
- Report a bug to the package maintainer.
- Check the comments at the top of the package's source file. If it contains a URL (specially on github), there's probably an issue tracker there.
- Some packages offer a command like
M-x PACKAGE-bug-report
.
- His or her email should be at the top of the package's source file.
- If it's a built-in package, you can report it with
M-x report-emacs-bug
.
- Even for packages that are not built-in, you can ask for help at the
help-gnu-emacs
mailing list.
C-h m
will reveal major mode and all minor modes that are active. You can slowly disable each minor-mode until you track down the cause. It could be the major mode itself, but the minor modes are the most likely suspects. Without specifying which modes you are using, anyone here would be just stabbing in the dark at what is going on with your issue. I have a rare situation that occurs with some special images -- e.g., when someone e-mails me something with a telephone symbol or other special symbols in the iPhone -- but that is an isolated slow-down issue caused by special symbols.linum-mode
slows down performance in large buffers.nlinum-mode
written by Stefan is better for larger buffers.