From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#74357: c-mode: Some syntactic constructs cause unreasonable typing lag Date: Fri, 15 Nov 2024 09:40:21 +0200 Message-ID: <86v7wphrmi.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25785"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 74357@debbugs.gnu.org To: =?UTF-8?Q?Bj=C3=B6rn?= Lindqvist , Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 15 08:41:10 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tBqx4-0006Xo-D1 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 15 Nov 2024 08:41:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBqwy-0002vH-GU; Fri, 15 Nov 2024 02:41:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBqww-0002v9-Q4 for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2024 02:41:02 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tBqww-0001MG-9Q for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2024 02:41:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-version:References:In-Reply-To:From:Date:To:Subject; bh=nSvzQAqeeo3g4163bjXlXhYvWyS1lExNYz1uCTwedTU=; b=pKloOa+/R/AFtCNA7KP1PRpcS8O5VSKQg071OZNfq3SlvkfrfzqeVfhtVtBWHePvGAWZQET1pn0SuKTpGE+WFROokp/3QiLmX7/2VQLuZ7EymboLdSRbXvAhtc33qKF7hyANkH1TW5djuJwhUhB8e0wT72zL2I9p0KHzpqfRHaQR064gIrwZGemEUWtxiY1J8HnGz4wn99IxG7zkYODnpC6rBBkWKiGf75QOEBcHn1yPaLpSl1WI4ZHVojOP0q9CDkflkHGp8ZCxSvwvyIVjFfSXLuwEGNYieogJI9DrTiXez01mh6/d26IxJUTemvwG1tMp/23Jffl8W4ysgzsvFg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tBqww-0006hB-42 for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2024 02:41:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Nov 2024 07:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74357 X-GNU-PR-Package: emacs Original-Received: via spool by 74357-submit@debbugs.gnu.org id=B74357.173165643725698 (code B ref 74357); Fri, 15 Nov 2024 07:41:02 +0000 Original-Received: (at 74357) by debbugs.gnu.org; 15 Nov 2024 07:40:37 +0000 Original-Received: from localhost ([127.0.0.1]:48375 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBqwX-0006gQ-8P for submit@debbugs.gnu.org; Fri, 15 Nov 2024 02:40:37 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:34010) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBqwW-0006gD-0P for 74357@debbugs.gnu.org; Fri, 15 Nov 2024 02:40:36 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBqwQ-0001GD-Ho; Fri, 15 Nov 2024 02:40:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=nSvzQAqeeo3g4163bjXlXhYvWyS1lExNYz1uCTwedTU=; b=hhYGSNzq5PhS/58yQr8e Ti0lRpMeU9ayGHWUX720jno0TbEP1JbqXQgx6NF44P5NnHsHACJLaLrJDt9/6SvfBSuk+MZPg9Iaw iZhpaz2x7SZenHysZCidC7CCyFW9n5qUmcgoyO7wY+olcDBT2hLn9Ww1YmIyufM4m35MfAerVL7kp 46axrKZ/pNkU5DqgRbSLR4KcUGbCnidYO0kqMje8ue/PHxbgUCHbHPGqPer8vmBCvdscBgAFFLEqO venBHynG0kcyVK2htvUrir7lOic9s9VKJchqdefpbxATLcJDeQsf4m83URpjl4+5bhMZzZUhAfFCu m/M/iwsKtw07KA==; In-Reply-To: (message from =?UTF-8?Q?Bj=C3=B6rn?= Lindqvist on Thu, 14 Nov 2024 21:39:53 +0100) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:295382 Archived-At: > From: Björn Lindqvist > 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.