Emacs: some problems of slowdown (tabbar, font)
Sometimes i noticed that emacs slows down. The problem is hard to track. Here's my experiences.
tabbar-mode slowdown. I've noticed in past years that tabbar-mode slows down emacs. Just re-affirmed it today. In today's case, it significantly slows down your emacs if you
have lots of files open. For example, i have 300 files open.
(they are opened by
[see Emacs: Find Replace Text in Directory]
Then, calling “M-x”
(execute-extended-command) takes 3 seconds to show the prompt. Opening a file
also take a few seconds. This is not always reproducible though. For example,
right now i still have 300+ files open, but the problem went away.
If you have desktop-save-mode on, and you have 300 files from last session. Starting emacs (with tabbar-mode one) can take a long time.
Set Keyboard Repeat Rate to Test Slow Down. When slow down happens, i notice it because emacs can't keep up with your typing. Here's a sure way to test a slow down. I have my key repeated rate set to the highest in Windows (or Mac), and onset delay to the lowest. Normally, if i hold a key, it'll repeat fast something like 18 char per second, and the chars appears on the screen continuously (as opposed in bursts). You can also test this by holding the right arrow key on a long paragraph.
When emacs slow down happens, the screen update happens in bursts. For example: I hold a key, nothing happens in screen, and every 1 seconds or 2 they appear.
Font May Cause Slowdown. Also, related but i don't know exactly what's going on yet … sometimes i noticed a slow down in emacs that has to do with what font you are using, and probably related to what chars you have in the current buffer (For example, Chinese or Unicode math symbols). When this happens, if i switch font to “Lucida Sans Unicode-10”, then the problem goes away. The worst seems to be the default font Courier New.
Same Buffer in Multiple Windows May Cause Slowdown. If you have the same buffer displayed in more than one windows (what emacs call “frames”), that may also slow down.
This is “GNU Emacs 23.2.1 (i386-mingw-nt6.0.6002) of 2010-05-08 on G41R2F1”, “ErgoEmacs distribution 1.9.2”
I don't think this problem is specific to ErgoEmacs, but probably Windows+Emacs, or just my particular machine.
If you want to experiment with the font problem, you'll need to install Lucida Sans Unicode and the DejaVu font set. (you should anyway, they are the best font if you do a lot coding and viewing a lot Unicode math symbols.) Lucida Sans Unicode is the best variable-width Unicode font. DejaVu Mono best for fixed-width (for Python, dired.). (See: Best Unicode Fonts for Programer for download location.)
then, to switch between your fav fonts, use this code:
(defun cycle-font-2 (num) "Change font in current frame between 2 fonts.." (interactive "p") ;; this function sets a property “state”. It is a integer. Possible values are any index to the fontList. (let (fontList fontToUse currentState nextState ) ;; (setq fontList (list "DejaVu Sans Mono-10" "Lucida Console-10" )) ; fixed-width ;; (setq fontList (list "DejaVu Sans-10" "Lucida Sans Unicode-10" )) ; variable-with (setq fontList (list "DejaVu Sans Mono-10" "Lucida Sans Unicode-10" )) ; variable-with / fixed-width (setq currentState (if (get 'cycle-font-2 'state) (get 'cycle-font-2 'state) 0)) (setq nextState (% (+ currentState (length fontList) num) (length fontList))) (setq fontToUse (nth nextState fontList)) (set-frame-parameter nil 'font fontToUse) (redraw-frame (selected-frame)) (message "Current font is: %s" fontToUse ) (put 'cycle-font-2 'state nextState) ) )
(For detail about this code, see: How to Quickly Switch Fonts in Emacs.)
Give it a hotkey. [see Emacs: How to Define Keys]
If you have a question, put $5 at patreon and message me.