From: "Mattias Engdegård" <mattias.engdegard@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Andrew Cohen <acohen@ust.hk>,
64391@debbugs.gnu.org, Gregory Heytings <gregory@heytings.org>,
Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#64391: buffer narrowing slowdown regression in emacs 29
Date: Sun, 2 Jul 2023 11:37:53 +0200 [thread overview]
Message-ID: <C483C339-7ACB-4B39-9777-1D70A67BCB2C@gmail.com> (raw)
In-Reply-To: <50A46AAC-2089-45CB-A355-CCB2B4EA8D76@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 717 bytes --]
How expensive markers can be when a buffer is modified is often unappreciated. Here are the results of a benchmark to illustrate the cost (code attached).
A buffer contains "abababab...", we optionally add a marker to every other position, and then time the deletion of all the "a"s. Results:
| size | without markers | with markers |
|--------+-----------------+--------------|
| 500 | 0.000 | 0.001 |
| 1000 | 0.001 | 0.004 |
| 5000 | 0.002 | 0.089 |
| 10000 | 0.005 | 0.363 |
| 50000 | 0.024 | 9.527 |
| 100000 | 0.049 | 58.048 |
Now there's something for the curve-fitters among you.
[-- Attachment #2: abench4.el --]
[-- Type: application/octet-stream, Size: 1519 bytes --]
;;; -*- lexical-binding: t -*-
(require 'cl-lib)
(defun abench-run ()
(let ((buffer-undo-list t))
(goto-char (point-min))
(while (not (eobp))
(delete-char 1)
(forward-char))))
(defun abench (size use-markers)
(with-temp-buffer
;; Populate buffer
(insert (mapconcat #'identity (make-list size "ab") nil))
;; Insert markers
(let ((markers nil))
(when use-markers
(dotimes (i size)
(push (set-marker (make-marker) (* i 2)) markers)))
;; Run operation
(garbage-collect)
(let ((gcs0 gcs-done)
(gc-e0 gc-elapsed)
(t0 (float-time)))
(abench-run)
(let ((dt (- (float-time) t0))
(gcs (- gcs-done gcs0))
(gc-time (- gc-elapsed gc-e0)))
(cl-assert
(equal (buffer-string)
(mapconcat #'identity (make-list size "b") nil)))
(list dt gcs gc-time))))))
(defun abench-main ()
(princ (format "Emacs %s\n" emacs-version))
(princ (format "| size | without markers | with markers |\n"))
(princ (format "|------+-----------------+--------------|\n"))
(dolist (size '(500 1000 5000 10000 50000 100000))
(let ((res-without (abench size nil))
(res-with (abench size t)))
(princ (format "| %d | %.3f | %.3f |\n"
size
(nth 0 res-without)
(nth 0 res-with)))))
(princ (format "|------+-----------------+--------------|\n"))
)
(abench-main)
next prev parent reply other threads:[~2023-07-02 9:37 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-01 0:15 bug#64391: 30.0.50; buffer narrowing slowdown regression in emacs 29 Andrew Cohen
2023-07-01 2:45 ` bug#64391: bug 64391 wrong git info Andrew Cohen
2023-07-01 4:59 ` bug#64391: more info Andrew Cohen
2023-07-01 11:37 ` bug#64391: buffer narrowing slowdown regression in emacs 29 Mattias Engdegård
2023-07-01 12:08 ` Eli Zaretskii
2023-07-01 12:52 ` Mattias Engdegård
2023-07-02 7:35 ` Gregory Heytings
2023-07-05 11:57 ` Eli Zaretskii
2023-07-06 14:41 ` Gregory Heytings
2023-07-06 17:33 ` Gregory Heytings
2023-07-06 18:22 ` Eli Zaretskii
2023-07-06 18:45 ` Gregory Heytings
2023-07-07 9:30 ` Mattias Engdegård
2023-07-07 10:00 ` Gregory Heytings
2023-07-07 10:23 ` Eli Zaretskii
2023-07-07 10:31 ` Gregory Heytings
2023-07-07 12:41 ` Eli Zaretskii
2023-07-07 12:46 ` Gregory Heytings
2023-07-07 11:33 ` Mattias Engdegård
2023-07-07 12:42 ` Gregory Heytings
2023-07-07 15:49 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-08 20:58 ` Gregory Heytings
2023-07-08 21:42 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-08 22:21 ` Gregory Heytings
2023-07-08 23:22 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-09 16:03 ` Gregory Heytings
2023-07-09 18:57 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-09 6:03 ` Eli Zaretskii
2023-07-09 8:35 ` Gregory Heytings
2023-07-09 8:52 ` Eli Zaretskii
2023-07-09 16:04 ` Gregory Heytings
2023-07-09 16:39 ` Eli Zaretskii
2023-07-09 18:03 ` Gregory Heytings
2023-07-09 18:52 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-09 19:19 ` Gregory Heytings
2023-07-09 19:42 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-09 19:44 ` Gregory Heytings
2023-07-09 19:03 ` Eli Zaretskii
2023-07-09 19:06 ` Eli Zaretskii
2023-07-09 19:29 ` Gregory Heytings
2023-07-07 10:27 ` Eli Zaretskii
2023-07-07 11:27 ` Mattias Engdegård
2023-07-07 12:50 ` Eli Zaretskii
2023-07-07 16:49 ` Mattias Engdegård
2023-07-07 18:22 ` Eli Zaretskii
2023-07-08 8:01 ` Eli Zaretskii
2023-07-08 19:41 ` Gregory Heytings
2023-07-02 9:37 ` Mattias Engdegård [this message]
2023-07-01 7:07 ` bug#64391: 30.0.50; " Eli Zaretskii
2023-07-01 7:31 ` Andrew Cohen
2023-07-01 8:09 ` Eli Zaretskii
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=C483C339-7ACB-4B39-9777-1D70A67BCB2C@gmail.com \
--to=mattias.engdegard@gmail.com \
--cc=64391@debbugs.gnu.org \
--cc=acohen@ust.hk \
--cc=eliz@gnu.org \
--cc=gregory@heytings.org \
--cc=monnier@iro.umontreal.ca \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).