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: Fri, 5 Aug 2022 23:23:25 +0300 Message-ID: References: <837d46mjen.fsf@gnu.org> <8a3eaeef01be5bfaa5ef@heytings.org> <05388e8d8812bfa3695d@heytings.org> <83v8rf5894.fsf@gnu.org> <65cb7c73fd4a999cca00@heytings.org> <8c7321f2f3400a5db9be@heytings.org> <8c7321f2f388e5343475@heytings.org> <8c7321f2f36494299e61@heytings.org> <83v8rc2n1h.fsf@gnu.org> <64084296-1953-8ef8-5938-adfb6fb9b43f@yandex.ru> <83r11uzs8n.fsf@gnu.org> <14845631-c2ef-8371-8606-c858092e3192@yandex.ru> <83mtcizov2.fsf@gnu.org> <83h72qzheq.fsf@gnu.org> <25717d84-3411-a93a-3620-e04fe0571aff@yandex.ru> <83edxuzemr.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="3477"; 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 Fri Aug 05 22:24:29 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 1oK3rx-0000gf-Gi for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 Aug 2022 22:24:29 +0200 Original-Received: from localhost ([::1]:35308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oK3rw-0001x5-B9 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 Aug 2022 16:24:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oK3rW-0001wg-L1 for bug-gnu-emacs@gnu.org; Fri, 05 Aug 2022 16:24:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oK3rW-0000Ci-CK for bug-gnu-emacs@gnu.org; Fri, 05 Aug 2022 16:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oK3rV-0000yy-WB for bug-gnu-emacs@gnu.org; Fri, 05 Aug 2022 16:24: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: Fri, 05 Aug 2022 20:24:01 +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.16597310203745 (code B ref 56682); Fri, 05 Aug 2022 20:24:01 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 5 Aug 2022 20:23:40 +0000 Original-Received: from localhost ([127.0.0.1]:60637 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oK3r9-0000yK-3u for submit@debbugs.gnu.org; Fri, 05 Aug 2022 16:23:40 -0400 Original-Received: from mail-wm1-f50.google.com ([209.85.128.50]:33567) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oK3r4-0000y6-S6 for 56682@debbugs.gnu.org; Fri, 05 Aug 2022 16:23:38 -0400 Original-Received: by mail-wm1-f50.google.com with SMTP id a18-20020a05600c349200b003a30de68697so4366254wmq.0 for <56682@debbugs.gnu.org>; Fri, 05 Aug 2022 13:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=XK+S9bL+XcMOv5zUTLY4Ir2k7djXnt4ErhTZOICovRM=; b=ZrWfOMWT3j+kdn2hooBw4/W/AaXIxnNjkddJLr5ky9gKhe6UFPBbNuiS1uqpcX5YhA Q+XsrP/nnUWQoaZrkpRYEE9lf0UY14vqSoJ/XuiPnwsHy+jvP7TaEgMXkdS+moMccPXR Y5ji4BxorQ/B1pIzA6u+OfkCHuPTiK+LL/gKl4xjd96PY8aC1NW3fM/F9scQoMQOHY8w r9Nh43UesPgy4YYyNMQ7849TeIjLlLjm+Sj0yXZmXfA0hPZylAu1RnSk3Ga76WkBn6Px mRjbKdJvwGqb0k+1YusJoxVGJlWjtm1D5GQN5WwrnjIEL+UgK4CvSgJufMTwnJfGHMYi izYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=XK+S9bL+XcMOv5zUTLY4Ir2k7djXnt4ErhTZOICovRM=; b=qRo9NEEe30mhA6SefjSW+cc8Sg5HRAe5EFR2ik2HHF9GPHJTeocGaf+bo3IxR4x54Y SQ/TXMnLAPFmcSsaKGI4BNpqxfphFRF9rhCEj6Cbm7c4zOAZ5ozSL6G9FU+S8kvk1goQ S3TV1+yE6LnVjFiFX6OOL0fTujiWjlhQEA/Ri7wHn5DoW7/P2vzjnWssoarJTEHccJrJ Nre8YfUg1DqzEg73W1235reJTbB3OR9Va/qt15WWwBUJnS5USJoG2n8aUIMw7BieHsJ6 NLguDAEQq1WdJDWlMOyVIV08xY6Ze1fLl5ckDbGoBoe91TPrmpzBc1csqjm2pJOl6ofo 88PQ== X-Gm-Message-State: ACgBeo3WhrHSZOqRX+uKiLKtu8usrnlPYmzRA3I5Ae/oDKdNmh1rh1Aa CNY7sOYP6vl/DFOo6NPuuww= X-Google-Smtp-Source: AA6agR5kvJCj159CtAIq6vDVutLU2zfVep9sOSWq8OQMUFrBJbWxdh+UoA7TEEunxqIEsRoGP2SIug== X-Received: by 2002:a05:600c:35d6:b0:3a3:1c4f:6f46 with SMTP id r22-20020a05600c35d600b003a31c4f6f46mr5639949wmq.206.1659731008862; Fri, 05 Aug 2022 13:23:28 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id ay32-20020a05600c1e2000b003a2e7c13a3asm5759087wmb.42.2022.08.05.13.23.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Aug 2022 13:23:27 -0700 (PDT) Content-Language: en-US In-Reply-To: <83edxuzemr.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:238941 Archived-At: On 05.08.2022 22:14, Eli Zaretskii wrote: >> Date: Fri, 5 Aug 2022 22:01:24 +0300 >> Cc: 56682@debbugs.gnu.org, gregory@heytings.org, monnier@iro.umontreal.ca >> From: Dmitry Gutov >> >>> First, we need to establish that indeed parse-partial-sexp is called >>> in that manner in the relevant major modes (not just one of them), or >>> by font-lock itself regardless of the mode. >> >> It is called by font-lock itself, which ends up calling syntax-ppss, >> which does its job with parse-partial-sexp. > > In all modes, regardless of what the mode wants to highlight? Yes. As part of highlighting strings, for instance. It needs to know which intervals of characters are strings. And you can't really know that without scanning the buffer from the beginning. >>> Second, we need to establish that indeed this takes a large portion of >>> the time in the slow operations. Not just one particular operation, >>> but most or all of them. >> >> To establish that, I have described the experiment in the grandparent >> email (with scenarios 1,2a;1,2b;1,2a,2b), and performed it myself as well. >> >> But I'm talking about the slowdown observed when doing 'M->'. Not about >> any operations one might try to perform. Having said that, after the >> initial 'M->' most of navigation operations look snappy to me. So that's >> the slowdown I decided to investigate. > > We need to look at more than just M->. C-n/C-p, C-v/M-v, C-l are also > important, as are the time it takes from typing M-x or M-: until you > see the prompt in the minibuffer, and the time to update the display > after inserting or deleting a single character. I'm not seeing any particular sluggishness in these operations when visiting dictionary.json. >> All major modes we can currently use for JSON (the built-in js-mode and >> the two json-mode's in ELPA) inherit the value of >> syntax-propertize-function from js-mode. But there's no need for it: >> JSON doesn't have division, or regexps, or preprocessor directives, or >> embedded JSX structures. >> >> Setting syntax-propertize-function to nil speeds up parse-partial-sexp >> significantly. > > Thanks, so I guess we may have a solution for JSON files, if disabling > syntax-propertize-function doesn't have any downsides. What about > other modes that we see in files with long lines, like XML? Someone will need to test it with some typical large file. xml-mode (alias to nxml-mode) does have a syntax-propertize-function, but it's probably faster than js-syntax-propertize. > And how scalable is the solution you propose, i.e. how it behaves in > JSON files with a much longer lines? parse-partial-sexp is O(length of text span) Meaning, it scales linearly. You'll see a 10x delay in a JSON file that is 10x as large.