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:58:58 +0300 Message-ID: <83sg1n8t71.fsf@gnu.org> References: <179f6e4fa40.2816.cc5b3318d7e9908e2c46732289705cb0@dancol.org> <83fsxpbpn9.fsf@gnu.org> <83k0n09tkp.fsf@gnu.org> <837dj09p0e.fsf@gnu.org> <20210611232535.b4dyu3a2yxvdixys@Ergus> <87a6nw6jtf.fsf@telefonica.net> <20210612010844.45noqsg7wveeo3yw@Ergus> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16076"; mail-complaints-to="usenet@ciao.gmane.io" Cc: ofv@wanadoo.es, emacs-devel@gnu.org To: Ergus Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 12 08:59:51 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 1lrxcV-00043F-Cd for ged-emacs-devel@m.gmane-mx.org; Sat, 12 Jun 2021 08:59:51 +0200 Original-Received: from localhost ([::1]:53796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrxcU-0004lQ-2z for ged-emacs-devel@m.gmane-mx.org; Sat, 12 Jun 2021 02:59:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrxbp-00046J-7H for emacs-devel@gnu.org; Sat, 12 Jun 2021 02:59:09 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:34326) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrxbo-0003bo-K6; Sat, 12 Jun 2021 02:59:08 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3627 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 1lrxbn-0005Iq-Bo; Sat, 12 Jun 2021 02:59:08 -0400 In-Reply-To: <20210612010844.45noqsg7wveeo3yw@Ergus> (message from Ergus on Sat, 12 Jun 2021 03:08:44 +0200) 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:270743 Archived-At: > Date: Sat, 12 Jun 2021 03:08:44 +0200 > From: Ergus > Cc: emacs-devel@gnu.org > > BTW: Eli was concerned about the extra copy of the buffer text to send > it to tree-sitter. In this case the time to memcopy an array with all > xdisp text is ~0.00085 seconds. If the intent is to use buffer-(sub)string, then you forget the price of consing. That would trigger frequent GC cycles, which will all but kill the otherwise fast performance. > Any way if we don't want the copy we can use > ts_parser_set_included_ranges to exclude the gap and pass the text > pointer directly without any copy. I hope someone will try that and report the results. The other design issue with TS integration is that I'd like it to plug into the JIT font-lock interface of the display engine, so that we don't unnecessarily fontify parts of the buffer that won't be displayed, and always do fontify the parts that will be. I don't really care if TS actually processes a much larger chunk of text, if it does that quickly enough, but processing the resulting faces will take time on the Emacs side, and that is better avoided. More importantly, integration into JIT font-lock machinery means we don't need to use other hooks, which is a step back, since using such hooks for fontification was already shown to have serious problems in pre-21 Emacs: they don't always catch all the changes which require re-fontification.