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.devel Subject: Re: cc-mode fontification feels random Date: Sat, 12 Jun 2021 09:44:45 +0300 Message-ID: <83wnqz8tuq.fsf@gnu.org> References: <83k0n2cjg5.fsf@gnu.org> <83im2lbqmv.fsf@gnu.org> <179f6e4fa40.2816.cc5b3318d7e9908e2c46732289705cb0@dancol.org> <83fsxpbpn9.fsf@gnu.org> <83k0n09tkp.fsf@gnu.org> <837dj09p0e.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33777"; mail-complaints-to="usenet@ciao.gmane.io" Cc: rudalics@gmx.at, dancol@dancol.org, emacs-devel@gnu.org, monnier@iro.umontreal.ca, rms@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 12 08:45:55 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lrxP1-0008ev-2u for ged-emacs-devel@m.gmane-mx.org; Sat, 12 Jun 2021 08:45:55 +0200 Original-Received: from localhost ([::1]:44472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrxP0-00068j-4F for ged-emacs-devel@m.gmane-mx.org; Sat, 12 Jun 2021 02:45:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrxOB-0005NV-Az for emacs-devel@gnu.org; Sat, 12 Jun 2021 02:45:03 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:34166) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrxOA-0000HR-3s; Sat, 12 Jun 2021 02:45:02 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2761 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrxO3-0008Ij-Uo; Sat, 12 Jun 2021 02:44:56 -0400 In-Reply-To: (message from Alan Mackenzie on Fri, 11 Jun 2021 20:06:30 +0000) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:270740 Archived-At: > Date: Fri, 11 Jun 2021 20:06:30 +0000 > Cc: Stefan Monnier , dancol@dancol.org, > rudalics@gmx.at, rms@gnu.org, emacs-devel@gnu.org > From: Alan Mackenzie > > Why do we have a problem? If the time taken to fontify a window is less > than the auto-repeat time (the two times are close on a modern machine), > this is surely not a problem for somebody with such a machine. It could > be a problem for somebody with a slower machine, or running an > unoptimised Emacs. It is a problem given how much the current fast machines can do during that time. At 3 GHz, 30 msec of CPU time is equivalent to 100 million machine instructions. > > That is much better, but still too slow, IMO. Think: it's the time > > that it takes us to fontify a single windowful, only a couple of > > dozens of lines. Why does it take so long? > > It does a very thorough job. AFAIU, sm-c-mode doesn't. And it still takes tens of milliseconds. > For example, one bug fix from many years > ago that I remember involved the fontification of foo in the following: > > .... > int bar; > } foo; > > What face should foo have? To answer that, you've got to go back over > the brace expression to see what's there. If it's > > struct foo > { > int baz; > .... > > , we need font-lock-variable-name-face for foo. On the other hand, if we > have > > typedef struct foo > { > int baz; > .... > > , we need font-lock-type-face. Before the bug fix, foo just got variable > name face. scan-lists backward over the brace expression takes time, > particularly for something the size of struct frame or even bigger. We should either find a way of making this analysis faster, or give up on fontifying these two cases differently. It is IMO unacceptable that redisplay is slowed down so much by mode-specific fontifications.