--- Begin Message ---
Subject: |
c-mode: Some syntactic constructs cause unreasonable typing lag |
Date: |
Thu, 14 Nov 2024 21:39:53 +0100 |
This bug has been present in c-mode for at least a year, but I haven't
gotten around to report it. The reason is that bugs about latency are
erratic and tricky to triage. Typing when the cursor is on some
syntatic constructs in c-mode causes severe lag on the order of several
hundred milliseconds on my (admittedly slow) laptop. The lag
makes c-mode almost unusable. Here is an MWE:
void foo(uint dc_dim, uint sc_dim,
uint fy_dim, uint fx_dim,
__global const float * restrict F,
uint sy_dim, uint sx_dim,
__global const float * restrict S,
uint padding,
__global float * restrict D) {
uint dy_dim = sy_dim + 2 * padding - fy_dim + 1;
uint dx_dim = sx_dim + 2 * padding - fx_dim + 1;
// Place cursor at "y" in "dy_dim". Hold "y" and observe lag.
uint dn = dc_dim * dy_dim * dx_dim;
uint sn = sc_dim * sy_dim * sx_dim;
}
I can make typing even laggier by wrapping foo in foo, like this:
void foo(...) {
...
void foo(uint dc_dim, uint sc_dim,
uint fy_dim, uint fx_dim,
__global float * restrict F,
uint sy_dim, uint sx_dim,
__global float * restrict S,
uint padding,
__global float * restrict D) {
uint dy_dim = sy_dim + 2 * padding - fy_dim + 1;
uint dx_dim = sx_dim + 2 * padding - fx_dim + 1;
// Place cursor at d[y]_dim. Hold "y". Observe lag in c-mode.
uint dn = dc_dim * dy_dim * dx_dim;
uint sn = sc_dim * sy_dim * sx_dim;
}
}
The more times I wrap foo the slower c-mode gets. So if you have a
fast computer try nesting foo in foo 50 times... I have observed the
same annoying input lag on multiple computers and I don't use any
special c-mode configuration.
Please cc me as I'm not subscribed to the list.
GNU Emacs 29.4 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.43,
cairo version 1.18.2)
--
mvh/best regards Björn Lindqvist
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#74357: c-mode: Some syntactic constructs cause unreasonable typing lag |
Date: |
Tue, 10 Dec 2024 10:43:08 +0000 |
Hello, Björn.
On Fri, Dec 06, 2024 at 21:53:12 +0100, Björn Lindqvist wrote:
> Hi Alan,
> Den sön 1 dec. 2024 kl 18:49 skrev Alan Mackenzie <acm@muc.de>:
> > Hello, Björn.
> > I've committed the patch to the Emacs master branch, after having done a
> > little more optimisation on it. I haven't closed the bug, yet, though.
> > The question is, is the patch good enough to close the bug? What do you
> > think? On my timings, typing in 20 y's at Line 328 of your test file,
> > with the patch was approximately three times as fast as before it.
> Unfortunately, I'm not able to test your patch on my slow machine so
> that will have to wait until the next Emacs release hits the Arch
> repositories. But I'm quite happy with what you've accomplished
> already. Typing in c-mode feels much faster than before. Thanks!
Thanks for doing this testing. I'm happy it's been well received.
I've decided to close this bug, now, which I'm doing with this post.
Should the improvement prove insufficient on your slower machine, could
you possibly open another bug for it, please?
Thanks!
> --
> mvh/best regards Björn Lindqvist
--
Alan Mackenzie (Nuremberg, Germany).
--- End Message ---