all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefankangas@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>, Antero Mejr <antero@mailbox.org>
Cc: 68234@debbugs.gnu.org
Subject: bug#68234: [PATCH] Increase blink-matching-paren-distance by 300kb.
Date: Thu, 4 Jan 2024 15:08:35 -0800	[thread overview]
Message-ID: <CADwFkmkbyc1TioYHkAmg_MPpdzK3OEeAvyRVT5+zDtveYOD=GQ@mail.gmail.com> (raw)
In-Reply-To: <83v889wd16.fsf@gnu.org>

Eli Zaretskii <eliz@gnu.org> writes:

>> -(defcustom blink-matching-paren-distance (* 100 1024)
>> +(defcustom blink-matching-paren-distance (* 400 1024)
>>    "If non-nil, maximum distance to search backwards for matching open-paren.
>>  If nil, search stops at the beginning of the accessible portion of the buffer."
>> -  :version "23.2"                       ; 25->100k
>> +  :version "23.2"                       ; 25->100k->400k
>>    :type '(choice (const nil) integer)
>>    :group 'paren-blinking)
>
> Do people feel okay with increasing this value by a factor of 4?  This
> blinking is supposed to be very fast, so if this will slow down
> display, it's not TRT.

I benchmarked this on my old ~2013 GNU/Linux machine using:

  (progn
  (goto-char (point-max))
  (insert "}")
  (let ((minibuffer-message-timeout 0)
        (blink-matching-delay 0)
        (repeat 20) fst)
    (dolist (distance (number-sequence 100 1000 100))
      (let* ((blink-matching-paren-distance (* distance 1024))
             (time (car (benchmark-run repeat (blink-matching-open)))))
        (message "distance %-4dKB takes %-.3fs (x%.1f)"
                 distance
                 (/ time repeat)
                 (/ time (setq fst (or fst time))))))))

In src/lisp.h (176 KB/5607 lines), I get:

  distance 100 KB takes 0.011s (x1.0)
  distance 200 KB takes 0.015s (x1.3)
  distance 300 KB takes 0.015s (x1.3)
  distance 400 KB takes 0.015s (x1.3) *
  [etc.]

In src/xterm.c (945 KB/32842 lines), I get:

  distance 100 KB takes 0.010s (x1.0)
  distance 200 KB takes 0.017s (x1.6)
  distance 300 KB takes 0.025s (x2.4)
  distance 400 KB takes 0.034s (x3.3) *
  distance 500 KB takes 0.042s (x4.1)
  distance 600 KB takes 0.051s (x5.0)
  distance 700 KB takes 0.060s (x5.8)
  distance 800 KB takes 0.068s (x6.7)
  distance 900 KB takes 0.078s (x7.6)
  distance 1000KB takes 0.079s (x7.7)

I also tried this in a ridiculous 23 MB header file that I found in the
Linux kernel tree, which my Emacs opens in fundamental-mode:

  distance 100 KB takes 0.005s (x1.0)
  distance 200 KB takes 0.005s (x1.0)
  distance 300 KB takes 0.008s (x1.5)
  distance 400 KB takes 0.010s (x2.0) *
  distance 500 KB takes 0.013s (x2.5)
  distance 600 KB takes 0.015s (x3.1)
  distance 700 KB takes 0.018s (x3.6)
  distance 800 KB takes 0.020s (x4.1)
  distance 900 KB takes 0.023s (x4.6)
  distance 1000KB takes 0.025s (x5.1)

Humans can't perceive delays smaller than 100 ms, so my conclusion here
is that setting this to 400 KB shouldn't normally lead to any noticeable
slowdown.  On the other hand, we get improved correctness, which sounds
like a win.

We also have to take into account the compound effect with other
features (such as third-party packages) that also may be slowing things
down.  However, this should only affect typing closing parens, so maybe
correctness could still be considered more important.

Of course, we could also double (instead of quadruple) this number, and
get most of the benefits still.

Eli, do you have any preference?

Note finally that the above examined files are unusually large (as is
often the case in our tree).

PS. Out of interest, in a recent copy of the Linux kernel the median
    *.[ch] file size is ~5 KB.  In emacs/src, we have instead a median
    *.[ch] file size of ~21KB.





  reply	other threads:[~2024-01-04 23:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-03 18:37 bug#68234: [PATCH] Increase blink-matching-paren-distance by 300kb Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found] ` <handler.68234.B.170430710530123.ack@debbugs.gnu.org>
2024-01-03 18:48   ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-04 11:31     ` Eli Zaretskii
2024-01-04 23:08       ` Stefan Kangas [this message]
2024-01-05  7:49         ` Eli Zaretskii
2024-01-05 20:50           ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-05 21:10             ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-06  7:01             ` Eli Zaretskii
2024-01-06 12:09               ` Stefan Kangas
2024-01-09  5:56           ` Stefan Kangas
2024-01-04  4:50 ` Stefan Kangas
2024-01-04 19:22   ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-04 21:03 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-04 21:36   ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkmkbyc1TioYHkAmg_MPpdzK3OEeAvyRVT5+zDtveYOD=GQ@mail.gmail.com' \
    --to=stefankangas@gmail.com \
    --cc=68234@debbugs.gnu.org \
    --cc=antero@mailbox.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.