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: Sat, 6 Aug 2022 13:50:41 +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> <83a68hzz0a.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="29703"; 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 Sat Aug 06 12:51:21 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 1oKHOp-0007a8-O9 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Aug 2022 12:51:19 +0200 Original-Received: from localhost ([::1]:43370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oKHOo-00040E-6W for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Aug 2022 06:51:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oKHOY-0003zv-5n for bug-gnu-emacs@gnu.org; Sat, 06 Aug 2022 06:51:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43094) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oKHOX-0001Ya-Tc for bug-gnu-emacs@gnu.org; Sat, 06 Aug 2022 06:51:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oKHOX-00026J-OK for bug-gnu-emacs@gnu.org; Sat, 06 Aug 2022 06:51:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 Aug 2022 10:51: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.16597830548061 (code B ref 56682); Sat, 06 Aug 2022 10:51:01 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 6 Aug 2022 10:50:54 +0000 Original-Received: from localhost ([127.0.0.1]:32843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oKHOQ-00025x-3f for submit@debbugs.gnu.org; Sat, 06 Aug 2022 06:50:54 -0400 Original-Received: from mail-wr1-f53.google.com ([209.85.221.53]:33772) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oKHON-00025h-H6 for 56682@debbugs.gnu.org; Sat, 06 Aug 2022 06:50:52 -0400 Original-Received: by mail-wr1-f53.google.com with SMTP id v3so5830735wrp.0 for <56682@debbugs.gnu.org>; Sat, 06 Aug 2022 03:50:51 -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=bLe4yCOqWA8xsw8ER1WFYlFYlFeaq8lOToUON34885A=; b=Z7fldU/VsVRFESYdTfT0BQULeSxFhbSOg1AVTnuU2OMES5wUfqCMbYDIlJJlsWnjip 1zUP43iiCnFuFyvTMfXMrNANOkWFfzn/uAv4Mc7s+Bw1XL+rG3XJvMxtMTW14aKSJMnr gArfppFq50dnAPKw2/356K9yvE5G532RhBTPvL8d6SXKko7X/CXtY73+8e5rOSLv0Eum +G+tTgxLm7reNWsWNXB4IMUBXvMBCCE2TB2UzHxMm0dxbFqiKoNLmqsVp7hjyC73krVJ z6ai2gvC9wwvJmlyvT3h/ZC5HA66AMIyZM/BMh4NSX9BKnnT/Jvdz6MSQTYgTNimCP3d 1h8A== 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=bLe4yCOqWA8xsw8ER1WFYlFYlFeaq8lOToUON34885A=; b=w05b2hdc0q5MsN3/dilDBEETuaBQgR5blnOyKPB2RKbpdlEK+caBmHEHrP8n3Ny3r3 QqC43ySjDGgsF9tBaL6VeqaPrtwWjSdbxlW62yP7leAbgLqcHOkd0QFYzfeMsJsJo4l2 0P6us7MAuMYweymUxs1kapQLJ8UzfJElyjU+hXwrJ6sJ0tuaQehcle33HIRrZVTs+vZw MOKUeA0HhFhhAPrx4NZk+wcXBHt0nHGSc5uhNw4dsjIVMZyLzOdbkCcRzoqF+C4BO4+3 1gJ3u28qDyqWuitgNTPH/cstzy+m0punSTbCG5K6W/dr3jv1NGKRP0JFV98UqPFFZuG9 wSlg== X-Gm-Message-State: ACgBeo1c2ihu/djq7rTqGIPe6RtAdYMZnXhfMyzPC8wcOJdYjgEY2Pvi fxTG+5m3Nfo7fzLNpxt2tXg= X-Google-Smtp-Source: AA6agR6d7XR3b71I0CvLeKp50TdnsLkEWizJDLaSEqzbUQEqmWVKB6LnnubY/gBKbldxgOn//pycEw== X-Received: by 2002:a05:6000:693:b0:221:7a12:8d6a with SMTP id bo19-20020a056000069300b002217a128d6amr3406297wrb.290.1659783045539; Sat, 06 Aug 2022 03:50:45 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id j9-20020a05600c1c0900b003a529b7bc27sm2073635wms.9.2022.08.06.03.50.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Aug 2022 03:50:43 -0700 (PDT) Content-Language: en-US In-Reply-To: <83a68hzz0a.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:238966 Archived-At: On 06.08.2022 09:07, Eli Zaretskii wrote: >> Date: Fri, 5 Aug 2022 23:23:25 +0300 >> Cc: 56682@debbugs.gnu.org, gregory@heytings.org, monnier@iro.umontreal.ca >> From: Dmitry Gutov >> >>> 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. > > Numbers, please. You have a very fast machine, so what doesn't look > sluggish on your system could very well be so on others. How do you measure these operations including the redisplay lag? Anyway, all of these look instant. >>> 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) > > Isn't that the part you proposed to remove? I was asking about the > remaining parts. No, removing syntax-propertize-function just made parse-partial-sexp 5x faster here, resulting in much faster fontification near EOB. But in a large enough buffer, it's still going to be the slowest part. >> Meaning, it scales linearly. You'll see a 10x delay in a JSON file that >> is 10x as large. > > Linear scaling is less optimal than O(0), which is what the current > solution produces. Correct syntax highlighting requires parsing the buffer from the beginning. Otherwise we get random results, essentially. Just like depicted on my latest screenshot for downloadify.js: the beginning of the narrowed region ended up inside a string, and as a result several screenfuls were entirely mis-fontified, with strings and non-strings inverted.