From 9d84f5c4a187a41e4eba954018c9e9b9fcc46d2e Mon Sep 17 00:00:00 2001 From: JackJ30 Date: Tue, 13 May 2025 01:51:16 -0400 Subject: emacs article --- zola-static/content/about-me.md | 10 +++++- zola-static/content/about-this-site.md | 8 ++++- .../content/blog/emacs-garbage-collection.md | 40 ++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 zola-static/content/blog/emacs-garbage-collection.md (limited to 'zola-static/content') diff --git a/zola-static/content/about-me.md b/zola-static/content/about-me.md index 13b4889..9eef574 100644 --- a/zola-static/content/about-me.md +++ b/zola-static/content/about-me.md @@ -3,4 +3,12 @@ title = "About Me" template = "main-page.html" +++ -My name is Jack Jamison +My name is Jack Jamison. I'm an American software engineer studying at the [Rensselaer Polytechnic Institute](https://www.rpi.edu) in New York. I've been programming since I was a little kid. + +I enjoy GPU programming, cross-platform desktop application design, build systems, game development, and system administration. I'm also interested in operating systems and networking, but I haven't pursued them yet. + +I use Emacs as my text editor. I've spent a lot of time configuring it. If you want, you can check out my [dotfiles](https://github.com/JackJ30/dotfiles). + +If you want to talk to me, I would love to also. Feel to reach out at my [email](mailto:jackqjamison@gmail.com). + +![Handsome devil](/images/portrait.jpg) diff --git a/zola-static/content/about-this-site.md b/zola-static/content/about-this-site.md index ec41a95..b8b6499 100644 --- a/zola-static/content/about-this-site.md +++ b/zola-static/content/about-this-site.md @@ -3,4 +3,10 @@ title = "About This Site" template = "main-page.html" +++ -This site is generated with [zola](https://getzola.org). +# About this website +- The pages are generated from markdown files with [Zola](https://getzola.org). +- I use [Nginx](https://https://nginx.org/) as my web server. +- It is hosted on [Vultr](https://www.vultr.com/). +- [Epik](https://epik.com) is my domain registrar. + +There are no ads or trackers on this site. The source code is available on [github](https://github.com/JackJ30/jackjamison.xyz). diff --git a/zola-static/content/blog/emacs-garbage-collection.md b/zola-static/content/blog/emacs-garbage-collection.md new file mode 100644 index 0000000..1784be9 --- /dev/null +++ b/zola-static/content/blog/emacs-garbage-collection.md @@ -0,0 +1,40 @@ ++++ +title = "Solving Emacs Garbage Collection Stutters" +date = 2025-05-12 ++++ + +The more you load Emacs up with packages, the more it starts to show its age. Throw on a theme and an lsp client, and you might start to notice frequent stuttering. + +This problem was very frustrating for me - I dealt with it for months, and considered quitting Emacs altogether. I want to be able to hold `C-n` and linearly move down the document, micro-stutter *free*. + + +# Garbage Collection +It turns out that the problem wasn't that packages were executing slowly, it was the garbage that they were building up. Emacs' garbage collector waits until a byte threshold has been reached before executing. +> This value feels relatively low for a modern computer - only `800KB`. + +Once threshold is reached the garbage collection process takes time, and causes the stutter. If you want to see just how often this triggers the GC, try setting `garbage-collection-messages` to non nil (you might be surprised how often it triggers). As with most things in Emacs, you can tune this behaviour. + +Opinions differ. +- Some people recommend **increasing** the threshold, leading to longer times without triggering the GC but longer stutters. +- Others recommend **lowering** the threshold, causing more frequent GC triggers but smaller stutters. +- The minibuffer (especially with packages like `vertico`) can use a lot of memory, so some [recommend](https://bling.github.io/blog/2016/01/18/why-are-you-changing-gc-cons-threshold/) increasing the threshold only when using it. + +# The Solution +In my opinion, the best solution is to garbage collect **when idle**. When editing, you're often pausing briefly - and if there is little garbage, Emacs can collect it very quickly. +I also *basically* disable the threshold entirely when in the minibuffer. Here's the code from my `init.el`. + +```lisp +(defun my-minibuffer-setup-hook () + (setq gc-cons-threshold most-positive-fixnum)) + +(defun my-minibuffer-exit-hook () + (setq gc-cons-threshold 800000000)) + +(setq gc-cons-threshold most-positive-fixnum) + +(run-with-idle-timer 1.2 t 'garbage-collect) +``` + +I have been using this for a few months and it's worked perfectly. Even when I try my best to notice the garbage collection, I can't. + +> There is a package which does the same thing, called [the Garbage Collector Magic Hack](https://github.com/emacsmirror/gcmh). Personally I prefer a lower idle time, and keeping it in my own config. -- cgit v1.2.3