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 23:59:10 +0300 Message-ID: <22ae00b4-e7eb-a7cf-1443-2492f3c17701@yandex.ru> References: <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> <835yj5zkm4.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="20931"; 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 23:00:27 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 1oKQuE-0005FY-PM for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Aug 2022 23:00:22 +0200 Original-Received: from localhost ([::1]:58820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oKQuD-0001WI-MU for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Aug 2022 17:00:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oKQtu-0001WA-Vp for bug-gnu-emacs@gnu.org; Sat, 06 Aug 2022 17:00:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oKQtu-0003Ep-J1 for bug-gnu-emacs@gnu.org; Sat, 06 Aug 2022 17:00:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oKQtu-0005aD-7J for bug-gnu-emacs@gnu.org; Sat, 06 Aug 2022 17:00: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: Sat, 06 Aug 2022 21:00: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.165981956421394 (code B ref 56682); Sat, 06 Aug 2022 21:00:02 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 6 Aug 2022 20:59:24 +0000 Original-Received: from localhost ([127.0.0.1]:35496 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oKQtI-0005Yz-1f for submit@debbugs.gnu.org; Sat, 06 Aug 2022 16:59:24 -0400 Original-Received: from mail-wm1-f52.google.com ([209.85.128.52]:53090) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oKQtD-0005Yh-8D for 56682@debbugs.gnu.org; Sat, 06 Aug 2022 16:59:22 -0400 Original-Received: by mail-wm1-f52.google.com with SMTP id c22so2910405wmr.2 for <56682@debbugs.gnu.org>; Sat, 06 Aug 2022 13:59:19 -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=AQ2pgWI1pdKXnfdgsSQfEtgShhY+8roPoMI9qWL2onA=; b=clKxvRCk0LAnHzQmbQixV4EyBUsSvtbx/sJUnwv8f9Dsnlt387bQMDXj15I5brqfsd 7Uxri4ywUK3+gFC7aQpVshhe+soubJG2u4JGk6NqhjsWaBrzeIl0v+x5ljsjJnB4Wy5l Tu6hDjJcAJMfGhNaHLE8eXbBWULmjbwoiytDnPdyXvmabI3RBibR2Dxj2wH7j9k6t0TE jau9GBLZDsJCz0MPLlM8/FKk257J4BfB5lKjR0nBbVLz30Em96+t3jVoAP3fHOHKELfW TvtxjSe0iIXhn7uDY8tJvgwD+GFtOtzNUWMSg790+EtYfD10DV1qYlPq1CkGvk8DRscN DLHg== 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=AQ2pgWI1pdKXnfdgsSQfEtgShhY+8roPoMI9qWL2onA=; b=MxlGI8nCR1LQExAunDv8+GIWs/S50zOZoH0Ach/fZ3hDtvwHE0jbuIFnuF1nWpdxpz Qjj035eUlBnfNfvSUXMpjXPsLzbkUrVuFORCu0PDVw+TvdIFE5TPw8uS1H1CwqS5F/wK IZEhPIFqnv1VF0rjGwJbGxquX25O53Qxwyyt2/gyQyromB6NAlLDb9i7A9wik4IhvZNi lXj9LBL8zE7rVdLnHD3S7QQYl4wT6EqGsJyner49/A40u1qafPMxz/7z2YK3kfEna7w1 2e8ApEx5MBV8OHN2S9Srsu+ZB6GV1AUI8gfNVMfvd/WHoHS/uyaTuQvJIrmiphcmOEvj qC/g== X-Gm-Message-State: ACgBeo2lNiDqsQRUTUyvAphB4ab794iFANi93dMcWqFMoaloCHAPTBSd v+ZiMRzad/HYRrruC8nVRWw= X-Google-Smtp-Source: AA6agR7jAY+j8PO7vjHzoYHBKJCiNtQOBd1J7V/DDkhifB1JzflvFS2gm8oI4G7B1JkoppIro7DuXQ== X-Received: by 2002:a05:600c:3845:b0:3a3:19e8:829e with SMTP id s5-20020a05600c384500b003a319e8829emr13051022wmr.11.1659819553341; Sat, 06 Aug 2022 13:59:13 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id m8-20020a05600c3b0800b003a4f1385f0asm8642219wms.24.2022.08.06.13.59.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Aug 2022 13:59:12 -0700 (PDT) Content-Language: en-US In-Reply-To: <835yj5zkm4.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:238999 Archived-At: On 06.08.2022 14:17, Eli Zaretskii wrote: >> Date: Sat, 6 Aug 2022 13:50:41 +0300 >> Cc: 56682@debbugs.gnu.org, gregory@heytings.org, monnier@iro.umontreal.ca >> From: Dmitry Gutov >> >>>> 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? > > By timing them. With benchmark-run or similar, if it isn't slow > enough to be measured "by hand". How do I time 'M-x'? Anyway, here are some numbers: (benchmark 1 '(next-line 1)) => Elapsed time: 0.035137s Elapsed time: 0.061863s Elapsed time: 0.027261s (benchmark 1 '(cua-scroll-down 1)) => Elapsed time: 0.049362s Elapsed time: 0.050060s (benchmark 1 '(cua-scroll-up 1)) => Elapsed time: 0.012383s Elapsed time: 0.039984s (benchmark 1 '(recenter-top-bottom 1)) => Elapsed time: 0.042014s Elapsed time: 0.013934s I get very similar numbers on these operations with unmodified master in this file. >>> 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. > > Yes, and IMNSHO responsiveness is more important than correctness in > these cases. That's why I suggested that, possibly after some further optimization work on parse-partial-sexp and syntax-propertize, we decide which initial length of the file we can fontify correctly with decent speed. 1 MB, or 10 MB, something like that. And of course make that customizable.