From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#24048: 25.0.95; syntax-ppss can be slow Date: Mon, 25 Jul 2016 04:16:45 +0300 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1469409446 4996 80.91.229.3 (25 Jul 2016 01:17:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Jul 2016 01:17:26 +0000 (UTC) To: Aaron Jensen , 24048@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 25 03:17:15 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bRUWA-0000rV-PQ for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Jul 2016 03:17:15 +0200 Original-Received: from localhost ([::1]:58120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRUW9-0003GA-Pv for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Jul 2016 21:17:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRUW3-0003G2-CL for bug-gnu-emacs@gnu.org; Sun, 24 Jul 2016 21:17:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bRUVy-0007qZ-8D for bug-gnu-emacs@gnu.org; Sun, 24 Jul 2016 21:17:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52057) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRUVy-0007qS-4L for bug-gnu-emacs@gnu.org; Sun, 24 Jul 2016 21:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bRUVy-0004V1-1I for bug-gnu-emacs@gnu.org; Sun, 24 Jul 2016 21:17: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, 25 Jul 2016 01:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24048 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24048-submit@debbugs.gnu.org id=B24048.146940941617278 (code B ref 24048); Mon, 25 Jul 2016 01:17:01 +0000 Original-Received: (at 24048) by debbugs.gnu.org; 25 Jul 2016 01:16:56 +0000 Original-Received: from localhost ([127.0.0.1]:36161 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bRUVs-0004Uc-4u for submit@debbugs.gnu.org; Sun, 24 Jul 2016 21:16:56 -0400 Original-Received: from mail-wm0-f46.google.com ([74.125.82.46]:37574) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bRUVo-0004UN-Tp for 24048@debbugs.gnu.org; Sun, 24 Jul 2016 21:16:55 -0400 Original-Received: by mail-wm0-f46.google.com with SMTP id i5so135020978wmg.0 for <24048@debbugs.gnu.org>; Sun, 24 Jul 2016 18:16:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=wD+cY2VeckXhORCtOKzUOIv3ZMaXpCWr/4s6ZQpnBjA=; b=qDGL11F+zY2jq+4S1hlhOVt86dVXC2rwXKXUg+W1+p5NPcZFadFbQC0PTZZ22exhSK nboB3r00/EHN3WgIqDZvfUkSJ+MQv6NCeWt5Mk4MUA/9SKK/Hm5IlF6Iat4X4fQhhNQT M/+Y1eWy4cKClAXDYaAGQCw8AEr/WSDyeYga9ufvkIv4oePTPZ2Ux33wIOIwNOszc3kW PI5iEiphkurlthFoLuwfgH5P5cXAieOZQkSP1bzFrn+TEeJ16if2XOtgTCC7OqnO+hpo mVHX//jpDUzjv8iFMWZeseHsd7W4GYQ0tP1nwZR6xd4THUcVqDjYP75uUvNBk6WnZ/Aq ExxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=wD+cY2VeckXhORCtOKzUOIv3ZMaXpCWr/4s6ZQpnBjA=; b=Zdnoi34IDFqk4Rno6DCLAWMLnkqG8eFvFWV9TJYe0jZkYZb7C4ncjnKxSMfPUq3JKv d/APZjE1hkv3PV/nFNNikV1D6eSe+Dqofus/I5p+t7X92yVjMKGHHNIsgfwL7pIrSBPm kunqqB6dkSRqXLwhizlG37S5D+dJRQNiC7eFNLubsxTDAuG2Uy6MEpR4m39PN0XfB8Zk c6qEO/Q5bQmNXY9ll1STLt4wRWSwqQK7EbpgHRvhhVmj2PUMjeWVzJOCQERD26j01fk0 zrY370tFe0OuZeWsaHH3v38YpuKZdrZD2xkXb/6jZsx1iTJK6MdNFjz9F8NKuL/VR45V zvlw== X-Gm-Message-State: AEkoouuhtRctNR6PLdfvMmcb2otIPgW44Ln+2HG5ICKKoUxQUa5cioBMEgqLgB3cxy/GpQ== X-Received: by 10.28.157.148 with SMTP id g142mr18060975wme.2.1469409407247; Sun, 24 Jul 2016 18:16:47 -0700 (PDT) Original-Received: from [192.168.1.2] ([185.105.173.135]) by smtp.googlemail.com with ESMTPSA id iw1sm13032688wjb.20.2016.07.24.18.16.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Jul 2016 18:16:46 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:47.0) Gecko/20100101 Thunderbird/47.0 In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:121503 Archived-At: Hi Aaron, On 07/21/2016 05:29 PM, Aaron Jensen wrote: > > In certain situations, the caching of syntax-ppss can seem to be > insufficient for good performance when syntax-ppss is invoked in a tight > loop. smartparens is a popular package that currently invokes > syntax-ppss in a tight loop (about 30-100 times depending on how many > match pairs are configured). syntax-ppss has caching built in, but it is > willing to use a cache from a further back position and do a > `parse-partial-sexp` from the old position to the current. Afterwards, > it does not set the cache with the current position. As such, in the > pathological case, it can parse ~2000 characters 30-100 times in a tight > loop. This is slow enough to show up in profiling and affect typing > latency. > > To repro, install: > > smartparens (you can use > https://github.com/aaronjensen/smartparens/tree/limit-binding-of-case-fold-search > to alleviate a different performance issue which could distract in the > profiling) > elixir-mode Is there a way to reproduce it more easier? Maybe without smartparens, just with elixir-mode, if it's sufficient to illustrate the performance problem (I recall you stating parse-partial-sexp is also unusually slow in that major mode, for some reason). Here, I'm seeing some similar behavior with elisp-mode.el. I can open this file, evaluate (benchmark 1000 '(syntax-ppss)) at line 10, then move to line 70 and do it there, and see the latter result to be much faster. They're still below 100ms usually (even with 1000 repetitions), so that's hardly a good example of a performance problem, by itself. P.S. Please send a text email next time, we very much prefer them for various reasons, inability to sneak in a tracker like this among them: