reddit / emacs

High CPU usage in WSL with Emacs 29.0.50

RecentlyRezzed · 2022-05-17 09:52
The commit [make timer\_check even more resilient](https://github.com/emacs-mirror/emacs/commit/fa52782f5c4eaef7138534766dfc8a29465785b2) triggers some problem in WSL that results in high CPU usage. But it's clearly a problem on the WSL side of things. The behavior vanishes after converting the WSL distribution instance to WSL2. The output from `profiler-report`: Samples % Function 4003 69% - command-execute 4003 69% - call-interactively 3996 69% - byte-code 3996 69% - read-extended-command 3996 69% - completing-read 3996 69% - completing-read-default 7 0% - read-from-minibuffer 2 0% - command-execute 1 0% - call-interactively 1 0% funcall-interactively 7 0% + funcall-interactively 1572 27% - timer-event-handler 1572 27% - apply 1572 27% + #<compiled 0x1f688e8844f794b6> 210 3% - ... 206 3% Automatic GC 4 0% + minibuffer-complete I don't need a solution for this, but I've seen a few posts in this subreddit about Emacs in WSL, so perhaps I can save somebody some time chasing this problem.
whompyjaw · 2022-06-29 17:27
I am having this problem with WSLg. I am not sure what I can do to change this. GNU Emacs 29.0.50 Development version b6238a26c973 on master branch; build date 2022-06-24.
whompyjaw · 2022-06-29 17:48
[report](https://imgur.com/a/GLioR2N) (cpu only) seems similar to yours even with WSLg since i can't copy/paste on WSLg, lol...
RecentlyRezzed · 2022-06-29 18:42
I don't have a solution. My workaround is to delete the four lines that are added in this commit. In the long run I'll switch to the Windows build on Windows.
whompyjaw · 2022-06-29 20:36
Gotcha. I suppose I could also rebuild from 29.0.49 edit: Good point on using Windows. Sadly the windows build is kinda slow, but at this point, any slower than WSLg and wayland? lol... they CPU hogs are pretty annoying.
whompyjaw · 2022-06-30 22:46
If it's any insight at all, I don't run into this issue when using \`-nw\`. So I assume it has something to do with wayland, and how wslg hosts X apps (even though I compiled \`emacs --with-pgtk\`)
RecentlyRezzed · 2022-07-01 06:43
Yes, when I converted the image to WSL2, the issue disappeared also for me. As my Windows build is older, I can't use WSLg, so it was in text mode. Besides that I have to use Direct Access and that doesn't play nice with WSL2. But with WSL1, there is no difference. I have the issue both with X11 and in text mode.
Ghosty141 · 2022-09-01 18:27
So I'm also having this problem but I'm already running WSL2. Has it completely fixed this issue for you?
RecentlyRezzed · 2022-09-01 18:44
Well, I didn't have the problem when I was using WSL2 on the text console. But it was just about diagnosing the cause. I need DirectAccess and graphics. So my fix then was removing the problematic code lines. And whompyjaw apparently only had the problem with WSLg. So you could also try to start Emacs with -nw.
Ghosty141 · 2022-09-01 19:30
Yeah it seems to be a GUI problem, it's not happening in console mode.
RecentlyRezzed · 2022-09-01 19:48
The [bug](https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21380) that is supposed to be fixed by this commit is connected to GTK, so it does make sense. I myself switched to Emacs with Cygwin on Windows. I didn't want to deal with the X server that I had to use with WSL anymore. And the MinGW version did not work nicely with ssh. It's slow, especially running something like straight-pull-all, because git is also awfully slow, but I can live with it.
Ghosty141 · 2022-09-01 20:12
I'll see how usable HyperV is else I'm just gonna dual boot if I ever need a linux env. What annoys me a lot is that project.el currently has nasty bug that breaks project-wide search/replace if the project uses submodules, this is only fixed on the master branch iirc. Alos pgtk is also only available on master. I might have to try too patch 28 to incorporate these changes, the project.el one is simple but pgtk I haven't look at yet.