unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#74357: c-mode: Some syntactic constructs cause unreasonable typing lag
@ 2024-11-14 20:39 Björn Lindqvist
  2024-11-15  7:40 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Björn Lindqvist @ 2024-11-14 20:39 UTC (permalink / raw)
  To: 74357

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





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-11-29 23:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-14 20:39 bug#74357: c-mode: Some syntactic constructs cause unreasonable typing lag Björn Lindqvist
2024-11-15  7:40 ` Eli Zaretskii
2024-11-15 14:08   ` Björn Lindqvist
2024-11-15 14:25     ` Eli Zaretskii
2024-11-15 14:45       ` Alan Mackenzie
2024-11-15 21:43       ` Björn Lindqvist
2024-11-16 11:00         ` Eli Zaretskii
2024-11-28 20:03         ` Alan Mackenzie
2024-11-29 23:18           ` Alan Mackenzie

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).