bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#74357: c-mode: Some syntactic constructs cause unreasonable typing l


From: Eli Zaretskii
Subject: bug#74357: c-mode: Some syntactic constructs cause unreasonable typing lag
Date: Fri, 15 Nov 2024 09:40:21 +0200

> From: Björn Lindqvist <bjourne@gmail.com>
> 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.

I've wrapped the snippet with 50 foo, and I still don't see any
significant lags.

Does it matter where you type, for reproducing the lag?

Also, can you run this under a profiler (M-x profiler-start) and then
show the full expanded profile produced by "M-x profiler-report" after
several tens of seconds of typing with the lag?

Adding Alan to the discussion.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]