From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#67390: 28; shorthands-font-lock-shorthands assumes shorthand uses same separator Date: Wed, 29 Nov 2023 01:12:52 -0800 Message-ID: <87jzq0gb5x.fsf@ushin.org> References: <87a5r5ph3p.fsf@bernoul.li> <87msv2vmzf.fsf@bernoul.li> <878r6mzezo.fsf@ushin.org> <87sf4tg6ts.fsf@bernoul.li> <875y1po3nk.fsf@ushin.org> <871qccqmgi.fsf@ushin.org> <83bkbf9z1u.fsf@gnu.org> Reply-To: Joseph Turner Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10806"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67390@debbugs.gnu.org, Adam Porter , Eli Zaretskii , Jonas Bernoulli To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 29 10:30:14 2023 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 1r8GtZ-0002Zy-AA for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Nov 2023 10:30:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r8GtL-0006dy-PE; Wed, 29 Nov 2023 04:30:00 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r8GtH-0006dn-IR for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 04:29:55 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r8GtH-0003Nf-8S for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 04:29:55 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r8GtO-0000RI-9u for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 04:30:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Joseph Turner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 29 Nov 2023 09:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67390 X-GNU-PR-Package: emacs Original-Received: via spool by 67390-submit@debbugs.gnu.org id=B67390.17012501911642 (code B ref 67390); Wed, 29 Nov 2023 09:30:02 +0000 Original-Received: (at 67390) by debbugs.gnu.org; 29 Nov 2023 09:29:51 +0000 Original-Received: from localhost ([127.0.0.1]:48903 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8GtC-0000QO-3r for submit@debbugs.gnu.org; Wed, 29 Nov 2023 04:29:51 -0500 Original-Received: from out-177.mta0.migadu.com ([91.218.175.177]:29001) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8Gt6-0000Pr-MQ for 67390@debbugs.gnu.org; Wed, 29 Nov 2023 04:29:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ushin.org; s=key1; t=1701250175; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hNARGsaGDsF5wu76jhZV3D/AviKgjkArLRzFC4vd27M=; b=ixW4wAcjA5IAsPLX7ez7Ys9184J5UVYgc9At4UzHuYjm6CqjdMJJiLiheYJppkuC1msx2w nv57sLBIc4rUIQufFmqs8c9pgebZHNM5nMORWpkS24suMXR+n/a87cIBQZ9ujuO6L8HkC/ ffQIRBJy+uGsZuk0R5wwSEivNsmtzI+0wLGTqeggzUBTM1JbE8w7mDdt38KVnkJ8+3W/Vl vzcY0wciG4cR4j6XDBOkhj0GujqcSbYBGJzFa1gx8EbzNZ0K6vS3HqRWv9UecJ1EafUdL3 mSlVZBoZMVnvzpntcCjoa2Cl/VcrktLg2dkrTSlxhY69hgO9tViDUuLJoiBgRA== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-reply-to: X-Migadu-Flow: FLOW_OUT 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:275206 Archived-At: Jo=C3=A3o T=C3=A1vora writes: > On Mon, Nov 27, 2023, 12:12 Eli Zaretskii wrote: > > > From: Jo=C3=A3o T=C3=A1vora > > Date: Sun, 26 Nov 2023 22:02:01 +0000 > > Cc: Jonas Bernoulli , 67390@debbugs.gnu.org, > > Adam Porter > > > > On Sun, Nov 26, 2023 at 8:38=E2=80=AFPM Joseph Turner wrote: > > > > > > Jo=C3=A3o T=C3=A1vora writes: > > > > > > > On Sat, Nov 25, 2023 at 10:43=E2=80=AFPM Joseph Turner wrote: > > > > > > So, benchmarking it will have to be, I'm afraid, because AFAIK > > > > font-locking is a very performance sensitive area of Emacs. > > > > > > Yes. I would like to learn how to do this! > > > > I'm CCing Eli. > > > > In the past, ISTR, Eli suggested to benchmark such things by visiting a > > very large file in its beginning, then scrolling down by holding > > the down arrow or PgDn for some fixed time period, like 30 seconds. > > The Emacs that scrolls the farthest is the most performant. Not > > entirely fail-proof (other processes may interfere, etc), but not > > bad either. > > I still recommend this method. Something like the below: > > (defun scroll-up-benchmark () > (interactive) > (let ((oldgc gcs-done) > (oldtime (float-time))) > (condition-case nil (while t (scroll-up) (redisplay)) > (error (message "GCs: %d Elapsed time: %f seconds" > (- gcs-done oldgc) (- (float-time) oldtime)))))) > > Evaluate the above, and the invoke it at the beginning of a large > file. Then compare the timings with different font-lock arrangements. > > A variant is to scroll by N lines, not by pages. Just change the > above to call scroll-up with the argument of N, for example 1 (or any > other number, if you want). > > Joseph can you try these variations? They're slightly more exact. Also sh= ow at least one of the large lisp files or tell me how to generate > one. If you still don't find any significant slowdown, I think we can mer= ge your patch. I'm happy to try Eli's variation if you don't beat me to it ;) My large lisp file consisted of copy-pasting with a kbd macro the body of https://git.sr.ht/~ushin/hyperdrive.el/tree/master/item/hyperdrive-lib.el until the file reached ~50K lines -- well over the limit I expected to reach on my machine. One potential issue with the patch is that multiple shorthand prefixes might match, while assoc will return the first matching cons pair read-symbol-shorthand. For example in hyperdrive-lib.el, we use the following shorthands in order to display "//" instead of "/-" as the prefix separator for private symbols, like "h//format-entry" instead of "h/-format-entry": ;; read-symbol-shorthands: ( ;; ("he//" . "hyperdrive-entry--") ;; ("he/" . "hyperdrive-entry-") ;; ("h//" . "hyperdrive--") ;; ("h/" . "hyperdrive-")) However, if we rearrange the values like: ;; read-symbol-shorthands: ( ;; ("he/" . "hyperdrive-entry-") ;; ("he//" . "hyperdrive-entry--") ;; ("h/" . "hyperdrive-") ;; ("h//" . "hyperdrive--")) then shorthands doesn't add fontification for either "h//" or "he//". (This surprised me - I was expecting to see just the "h/" and "he/" highlit) However, I'm starting to wonder whether this is a case of user error. Should we avoid overlapping shorthand prefixes? Thank you!! Joseph