Improving Emacs Performance
My Emacs config has grown considerably over
the years. I love finding new packages to improve my workflow, and
MELPA/use-package
together make packages really easy to install.
But this is bad news if you want a fast and productive editing experience. A few weeks ago, some dastardly sluggishness when editing Rust code forced me to finally sit down and address the problem. Here are some Mrcnski Tips I’ve collected from the process.
Tips
- It helps a lot to cut down on frills you don’t need. Disable things like syntax checking as you type or make them run on save instead.
- Get rid of large, hefty packages like
helm
and use simpler ones, likevertico
. - Prefer built-in packages like
flymake
to third-party ones likeflycheck
. - Increase the GC threshold and set it to run when you tab out or go idle:
- I disabled my fancy modeline and
show-parens
and my experience is smoother. Try disabling one minor mode at a time and see how things feel with each change. - Also, use
M-x profiler-start
andprofiler-report
to profile runtime. - There’s also
esup
and thebenchmark-init
package for profiling startup, but I don’t much care about that.
Conclusion
As with all things, you will have to strike a balance between performance and functionality. I still get the occasional GC hiccup, and it bothers me some, but not enough to sacrifice the formidable 10x productivity increase I get from all my packages.