From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#56682: Fix the long lines font locking related slowdowns Date: Mon, 15 Aug 2022 13:06:14 +0300 Message-ID: References: <83mtcgy44k.fsf@gnu.org> <83k07jx5jn.fsf@gnu.org> <866e510d-a060-7daa-d002-97861d056fa7@yandex.ru> <1144021660321893@iva5-64778ce1ba26.qloud-c.yandex.net> <12348081660379417@sas2-a098efd00d24.qloud-c.yandex.net> <66bbbb95983414e79637@heytings.org> <66bbbb95983475c5f3b0@heytings.org> <0d67f253-c080-d750-c2cb-4a9591ff8c6c@yandex.ru> <83lerrl734.fsf@gnu.org> <83wnbbj7v4.fsf@gnu.org> <75c316c0-3346-e702-b114-41a7f899deb1@yandex.ru> <5900f20836ca3f305df8@heytings.org> <8ef8eaba-1add-e87e-247e-71888beaf1f8@yandex.ru> <837d3ak8lf.fsf@gnu.org> <14516fce-8c35-1ce7-1314-44a3d79e8ba7@yandex.ru> <834jyek7df.fsf@gnu.org> <29b571a3-5a47-fed9-3147-f30864134c41@yandex.ru> <83tu6ei6e0.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6354"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Cc: 56682@debbugs.gnu.org, gregory@heytings.org, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 15 12:10:10 2022 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 1oNX2v-0001WW-Q1 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Aug 2022 12:10:09 +0200 Original-Received: from localhost ([::1]:40822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNX2u-0005VZ-Q8 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Aug 2022 06:10:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNWzu-0002Tt-MJ for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2022 06:07:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51169) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oNWzu-00015K-DK for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2022 06:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oNWzu-0008H1-6t for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2022 06:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 Aug 2022 10:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56682 X-GNU-PR-Package: emacs Original-Received: via spool by 56682-submit@debbugs.gnu.org id=B56682.166055798531758 (code B ref 56682); Mon, 15 Aug 2022 10:07:02 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 15 Aug 2022 10:06:25 +0000 Original-Received: from localhost ([127.0.0.1]:40918 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNWzI-0008G9-FR for submit@debbugs.gnu.org; Mon, 15 Aug 2022 06:06:24 -0400 Original-Received: from mail-wr1-f54.google.com ([209.85.221.54]:41551) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNWzG-0008Fv-PV for 56682@debbugs.gnu.org; Mon, 15 Aug 2022 06:06:23 -0400 Original-Received: by mail-wr1-f54.google.com with SMTP id p10so8510454wru.8 for <56682@debbugs.gnu.org>; Mon, 15 Aug 2022 03:06:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc; bh=ve8/JWG3h1E1BVzES4Or9HoV7nmpAWzLbYwaZC1J/3o=; b=leY4LsqAYYQhktDYoHNOhLb0C6aex6gSvKTqzSiuWnlBHnlMcVRDbog49S9adXR883 //3AMZi4v7/Lb/AfdnCYakFMeasoGiQeWmC23YonLznXTd1XvIgVzTPTNtm7cJFpoXvw 0tLUDL4VctUjZHgc/NRL2q6Bgq3/tv7cEnYuDnBVwXgqt7JnvQ+OukteZ3qdLqZexT+Y 71sFsDI500isOGiMPEFKNRrXrMFgXV0IaMsHpjGsnvpooNwmTD05qaxcksMH7oslY380 PRfsLwh8DicoNPjESRkZw61o332zVw2+C9UZ7/ac/EPmnPnleo0ayBTBCYipM9drzN4f 3hhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc; bh=ve8/JWG3h1E1BVzES4Or9HoV7nmpAWzLbYwaZC1J/3o=; b=KVfMR2qZwkCLxBHycC1X3gz5SIhtlQCjIcoRUwqywVJk+vitG7gTuJAmx8ivWruKvx XipYfq4XxoFs2wN3hz9xjJ4yKX2u8vWcY9zEvqNTp0Dreko+DQmooGzAHQFalmhaebkL if3rgRRgfPzBBYXXb4g5wag8+MTTwDTC3EP8KhD60WnZ1pAzX0AQIjDf+4RgweQ5qBzj uCC6801sKNGM94YciAx+v9W/VLww84PoZdq/3AZMDkpWpqCi4NCCcMIrMn+FddwjeHfi L7+qK+qbdhc0xCPNiY+TbxhZnPTk51IzrXXmcTdpW7yRMpD0uP+4gvlc/pD19XcLAxoW Lbqg== X-Gm-Message-State: ACgBeo0f93GEOWGauWOB0enFaILKWwSALQ46+memTHGBtoCWW0TmXzH6 9oiQfi6+ZN2i260XpB17fZw= X-Google-Smtp-Source: AA6agR6BtLmK+h6veIudN/DChW4D90vyW3SommZSYrARKafyCvC+I3iLrrIzpd1MPyLuCdB8UQtn/g== X-Received: by 2002:adf:e44b:0:b0:220:5bc5:e942 with SMTP id t11-20020adfe44b000000b002205bc5e942mr8199627wrm.179.1660557976910; Mon, 15 Aug 2022 03:06:16 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id k5-20020a05600c1c8500b003a5dfd7e9eesm8647784wms.44.2022.08.15.03.06.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 Aug 2022 03:06:16 -0700 (PDT) Content-Language: en-US In-Reply-To: <83tu6ei6e0.fsf@gnu.org> 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" Xref: news.gmane.io gmane.emacs.bugs:239769 Archived-At: On 15.08.2022 05:32, Eli Zaretskii wrote: >> Date: Mon, 15 Aug 2022 01:07:08 +0300 >> Cc: 56682@debbugs.gnu.org, gregory@heytings.org, monnier@iro.umontreal.ca >> From: Dmitry Gutov >> >> On 14.08.2022 21:27, Eli Zaretskii wrote: >>>> Date: Sun, 14 Aug 2022 21:14:00 +0300 >>>> Cc: 56682@debbugs.gnu.org, gregory@heytings.org, monnier@iro.umontreal.ca >>>> From: Dmitry Gutov >>>> >>>> The implementation of the idea that Gregory mentioned (font locking >>>> reasonably accurate even when it doesn't have access to the whole >>>> buffer) will have to be done in Lisp anyway. So that's where the >>>> narrowing should be applied too. >>> >>> I don't see how it follows. If we decide (and I don't say we did, but >>> if we do) that fontification-functions must run narrowed, then they >>> will run narrowed, and the best place to do that is in the caller. >> >> Only if we somehow decided that it makes sense to always use the same >> narrowing bounds. But as experiment shows, font-lock can use 100x larger >> narrowing, and still perform well. > > So what? The proponents of the widening claim that they need to go to > BOB, and no "arbitrary" narrowing smaller than that will suffice. I'm trying to support several approaches, including narrowing. > And btw, I have very different impression of what happens with 100x > larger narrowing on my machine and with unoptimized builds. Given what we've seen about your parse-partial-sexp's performance (10x slower than mine), I would hope for someone to figure out why it's so slow in your unoptimized build. But if it doesn't happen, you would probably use a different threshold/narrowing radius (through customization). It would make sense for our defaults not to be tailored to this very particular development rig. >> Further, the thing which is going to call the language-specific >> safe-position-finding logic is likely to want to update the bounds of >> the narrowing (to then call syntax-ppss within those bounds, where START >> is a "safe" position). >> >> So yeah, the font-lock related widen/narrowing logic should indeed live >> in one place. And until now it has resided in font-lock-fontify-region. > > Since when is font-lock-fontify-region specific to a language? It is > as general as xdisp.c. syntax-propertize is general, and yet it invokes language-specific rules (through syntax-propertize-function).