all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: dmitry@gutov.dev, 66117@debbugs.gnu.org
Subject: bug#66117: 30.0.50; `find-buffer-visiting' is slow when opening large number of buffers
Date: Sat, 23 Sep 2023 11:57:03 +0300	[thread overview]
Message-ID: <83zg1d468w.fsf@gnu.org> (raw)
In-Reply-To: <87wmwh2tae.fsf@localhost> (message from Ihor Radchenko on Sat, 23 Sep 2023 08:22:17 +0000)

> From: Ihor Radchenko <yantar92@posteo.net>
> Cc: dmitry@gutov.dev, 66117@debbugs.gnu.org
> Date: Sat, 23 Sep 2023 08:22:17 +0000
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> Because `buffer-file-name' can be modified from Lisp (via
> >> `set-visited-file-name' or directly). Same for `buffer-file-truename'
> >> and `buffer-file-number'.
> >
> > You could update the cache in set-visited-file-name, and ignore
> > direct changes.
> 
> I have eyeballed Emacs sources, and it looks like a huge number of
> libraries sets `buffer-file-name' directly.

I think this is an exaggeration, see below.

> Also, even `find-file-noselect' does not use
> `set-visited-file-name'.

Why does it matter?  We need to catch this in find-file-noselect and
in set-visited-file-name anyway.

> - Functions setting ~buffer-file-name~ manually (except those setting it to nil):
>   - tests
>   - ~vc-find-revision-no-save~
>   - ~url-insert-buffer-contents~
>   - ~plstore-open~
>   - ~protect-innocence-hook~ (really?)
>   - ~tramp-handle-insert-file-contents~
>   - ~tramp-archive-handle-insert-file-contents~
>   - ~mailcap-view-file~
>   - ~ange-ftp-parse-netrc~
>   - ~ange-ftp-write-region~
>   - ~ange-ftp-insert-file-contents~
>   - ~mh-display-msg~
>   - ~mh-make-folder~
>   - ~mh-read-draft~
>   - ~feedmail-vm-mail-mode~
>   - ~feedmail-send-it~
>   - ~jka-compr-write-region~
>   - ~jka-compr-insert-file-contents~
>   - ~image-dired-write-tags~
>   - ~image-dired-remove-tag~
>   - ~image-dired-write-comments~
>   - ~hfy-buffer~
>   - ~nndraft-request-associate-buffer~
>   - ~nndraft-auto-save-file-name~
>   - ~nnbabyl-create-mbox~
>   - ~mm-display-inline-fontify~
>   - ~mm-url-insert-file-contents~
>   - ~mm-extern-url~
>   - ~message-send-mail-with-mh~
>   - ~message-set-auto-save-file-name~
>   - ~gnus-dribble-read-file~
>   - ~gnus-save-newsrc-file~
>   - ~gnus-gnus-to-newsrc-format~
>   - ~gnus-mime-copy-part~

IMO, these are not important for your purpose.  The few buffers whose
buffer-file-name is set as in those functions are not going to get in
the way of your looking for a buffer that visits a specific name.  And
if a few of them do, we can always add the cache-updating code to them.

>   - ~find-alternate-file~
>   - ~find-file-noselect-1~ (but not by default?)
>   - ~set-visited-file-name~
>   - ~file-name-non-special~

These _must_ update the cache.

>   - ~erc-dcc-find-file~
>   - ~epa-file-insert-file-contents~
>   - ~epa-file-write-region~
>   - ~save-completions-to-file~
>   - ~load-completions-from-file~
>   - ~archive-extract~

These belong to the first group, I think.

> - Functions setting ~buffer-file-truename~ manually (except those setting it to nil):

Are the cases where we find the buffer via file's truename significant
in the profiles you've seen? if not, these functions are not relevant
to the issue at hand.  If the search by truename _is_ significant, we
could cache that as well.

>   - ~tar-extract~
>   - ~find-alternate-file~
>   - ~find-file-noselect-1~
>   - ~set-visited-file-name~
>   - ~revert-buffer--default~
>   - ~archive-extract~
> 
> 
> - Functions setting ~buffer-file-number~ manually (except those setting it to nil):

Same question as for truename above.

>   - ~find-alternate-file~
>   - ~find-file-noselect-1~
>   - ~set-visited-file-name~
>   - ~basic-save-buffer~
> 
> 
> >> Or should we just assume that these variables remain unchanged other
> >> than by primitives?
> >
> > Programs that make these changes are asking for trouble, IMO.  AFAICT,
> > find-buffer-visiting will never find such buffers anyway.
> 
> It would, in its current form. Because it calls `get-file-buffer' that
> loops over all the buffers and checks their buffer-local
> `buffer-file-name' value, including values set via `setq' in Elisp.

Again, which of the loops took the significant time in the profiles
you have? the one in get-file-buffer or the ones in
find-buffer-visiting?





  reply	other threads:[~2023-09-23  8:57 UTC|newest]

Thread overview: 162+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-20  8:53 bug#66117: 30.0.50; `find-buffer-visiting' is slow when opening large number of buffers Ihor Radchenko
2023-09-22  1:36 ` Dmitry Gutov
2023-09-22 11:03   ` Ihor Radchenko
2023-09-22 12:11     ` Dmitry Gutov
2023-09-22 12:41       ` Ihor Radchenko
2023-09-22 12:59         ` Eli Zaretskii
2023-09-22 13:30           ` Ihor Radchenko
2023-09-22 14:57             ` Eli Zaretskii
2023-09-23  8:22               ` Ihor Radchenko
2023-09-23  8:57                 ` Eli Zaretskii [this message]
2023-09-24 10:54                   ` Ihor Radchenko
2023-09-24 12:50                     ` Eli Zaretskii
2023-09-26  8:54                       ` Ihor Radchenko
2023-09-26 14:18                         ` Michael Albinus
2023-10-04 10:57                           ` Ihor Radchenko
2023-09-26 11:11                       ` Dmitry Gutov
2023-09-26 13:06                     ` Ihor Radchenko
2023-09-27 23:30                       ` Michael Heerdegen
2023-10-05 14:25                         ` Ihor Radchenko
2023-09-29  7:30                       ` Eli Zaretskii
2023-09-29 13:56                         ` Ihor Radchenko
2023-09-29 16:12                           ` Eli Zaretskii
2023-10-03  3:25                             ` Michael Heerdegen
2023-10-03  6:00                               ` Eli Zaretskii
2023-10-07  8:25                             ` Ihor Radchenko
2023-10-07  8:48                               ` Eli Zaretskii
2023-10-07  9:29                                 ` Ihor Radchenko
2023-10-07 10:57                                   ` Eli Zaretskii
2023-10-07 11:08                                     ` Ihor Radchenko
2023-10-07 11:24                                       ` Eli Zaretskii
2023-10-07 11:43                                         ` Ihor Radchenko
2023-10-07 12:05                                           ` Eli Zaretskii
2023-10-08  9:00                                             ` Ihor Radchenko
2023-10-08  9:56                                               ` Eli Zaretskii
2023-10-09 10:02                                                 ` Ihor Radchenko
2023-10-09 10:16                                                   ` Ihor Radchenko
2023-12-12 14:24                                                     ` Ihor Radchenko
2023-12-12 14:49                                                       ` Eli Zaretskii
2023-12-12 16:33                                                         ` Ihor Radchenko
2023-12-12 17:26                                                           ` Eli Zaretskii
2023-12-12 17:44                                                             ` Ihor Radchenko
2023-12-12 18:36                                                               ` Eli Zaretskii
2023-12-12 19:10                                                                 ` Dmitry Gutov
2023-12-12 19:16                                                                   ` Eli Zaretskii
2023-12-12 19:18                                                                 ` Ihor Radchenko
2023-12-12 19:20                                                                   ` Eli Zaretskii
2023-12-12 20:01                                                           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-12 20:47                                                             ` Dmitry Gutov
2023-12-12 22:57                                                               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-12 23:40                                                                 ` Dmitry Gutov
2023-12-13  3:50                                                                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-12 23:09                                                               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-12 23:43                                                                 ` Ihor Radchenko
2023-12-12 23:47                                                                   ` Dmitry Gutov
2023-12-13  3:55                                                                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-13 12:10                                                                       ` Eli Zaretskii
2023-12-13 13:06                                                                         ` Ihor Radchenko
2023-12-13 13:25                                                                           ` Eli Zaretskii
2023-12-13 13:43                                                                             ` Ihor Radchenko
2023-12-13 13:51                                                                               ` Eli Zaretskii
2023-12-13 14:12                                                                                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-13 14:58                                                                                   ` Eli Zaretskii
2023-12-13 14:32                                                                                 ` Ihor Radchenko
2023-12-13 15:22                                                                                   ` Eli Zaretskii
2023-12-14 14:20                                                                                     ` Ihor Radchenko
2023-12-14 16:40                                                                                       ` Eli Zaretskii
2023-12-14 17:07                                                                                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-14 17:14                                                                                           ` Eli Zaretskii
2023-12-14 18:11                                                                                             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-14 18:30                                                                                               ` Ihor Radchenko
2023-12-14 18:41                                                                                                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-14 19:02                                                                                                   ` Ihor Radchenko
2023-12-14 19:36                                                                                                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-15 11:01                                                                                                       ` Ihor Radchenko
2023-12-15 13:47                                                                                                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-17  6:04                                                                                                         ` Eli Zaretskii
2023-12-17  6:11                                                                                                           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-17  8:30                                                                                                             ` Eli Zaretskii
2023-12-17 10:31                                                                                                               ` Ihor Radchenko
2023-12-17 10:36                                                                                                                 ` Eli Zaretskii
2023-12-17 10:46                                                                                                                   ` Eli Zaretskii
2023-12-17 10:56                                                                                                                     ` Ihor Radchenko
2023-12-17 11:06                                                                                                                       ` Eli Zaretskii
2023-12-17 11:19                                                                                                                         ` Ihor Radchenko
2023-12-17 12:06                                                                                                                           ` Eli Zaretskii
2023-12-19 13:24                                                                                                                             ` Ihor Radchenko
2023-12-19 13:38                                                                                                                               ` Eli Zaretskii
2023-12-20 20:33                                                                                                                               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-21  5:56                                                                                                                                 ` Gerd Möllmann
2023-12-21 13:25                                                                                                                                 ` Ihor Radchenko
2023-12-21 13:39                                                                                                                                   ` Gerd Möllmann
2024-01-01 18:02                                                                                                                                     ` Ihor Radchenko
2024-01-01 19:39                                                                                                                                       ` Gerd Möllmann
2024-01-01 20:39                                                                                                                                         ` Ihor Radchenko
2024-01-02  4:43                                                                                                                                           ` Gerd Möllmann
2024-01-02 10:52                                                                                                                                             ` Ihor Radchenko
2024-01-02 11:08                                                                                                                                               ` Gerd Möllmann
2024-01-02 11:17                                                                                                                                                 ` Ihor Radchenko
2024-01-02 11:48                                                                                                                                                   ` Gerd Möllmann
2024-01-02 12:07                                                                                                                                                     ` Ihor Radchenko
2024-01-02 12:07                                                                                                                                                       ` Gerd Möllmann
2024-01-02 12:15                                                                                                                                                         ` Ihor Radchenko
2024-01-02 12:57                                                                                                                                                           ` Gerd Möllmann
2024-01-02 13:09                                                                                                                                                             ` Ihor Radchenko
2024-01-02 13:28                                                                                                                                                               ` Gerd Möllmann
2024-01-03 14:28                                                                                                                                                                 ` Gerd Möllmann
2024-01-02  1:30                                                                                                                                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-02 11:00                                                                                                                                         ` Ihor Radchenko
2024-01-02 11:57                                                                                                                                           ` Gerd Möllmann
2024-01-02 12:11                                                                                                                                             ` Ihor Radchenko
2024-01-03  2:13                                                                                                                                           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-02 11:08                                                                                                                                       ` Ihor Radchenko
2024-01-02 14:08                                                                                                                                         ` Gerd Möllmann
2023-12-17 15:17                                                                                                                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-17 16:02                                                                                                                           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-17 10:52                                                                                                                   ` Ihor Radchenko
2023-12-17 11:01                                                                                                                     ` Eli Zaretskii
2023-12-17 11:26                                                                                                                       ` Ihor Radchenko
2023-12-17 12:14                                                                                                                         ` Eli Zaretskii
2023-12-17 15:24                                                                                                                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-14 18:49                                                                                               ` Eli Zaretskii
2023-12-14 19:49                                                                                                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-14 20:24                                                                                                   ` Eli Zaretskii
2023-12-14 20:57                                                                                                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-14 21:32                                                                                                       ` Dmitry Gutov
2023-12-14 23:03                                                                                                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-14 19:15                                                                                             ` Ihor Radchenko
2023-12-14 19:56                                                                                               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-15 10:19                                                                                                 ` Ihor Radchenko
2023-10-08 11:16                                               ` Dmitry Gutov
2023-10-08 11:25                                                 ` Ihor Radchenko
2023-10-08 11:44                                                   ` Eli Zaretskii
2023-10-08 12:10                                                     ` Ihor Radchenko
2023-10-08 12:28                                                     ` Dmitry Gutov
2023-10-08 12:11                                                   ` Dmitry Gutov
2023-10-08 12:20                                                     ` Ihor Radchenko
2023-10-09  0:48                                                       ` Dmitry Gutov
2023-12-23  8:54                                               ` Eli Zaretskii
2023-12-23  9:41                                                 ` Ihor Radchenko
2023-12-23 11:16                                                   ` Eli Zaretskii
2023-12-23 11:28                                                     ` Ihor Radchenko
2023-12-23 11:51                                                       ` Eli Zaretskii
2023-12-23 14:30                                                         ` Ihor Radchenko
2023-12-30  7:39                                                           ` Eli Zaretskii
2023-12-29  7:47                                                       ` Eli Zaretskii
2023-12-29 13:55                                                         ` Ihor Radchenko
2023-12-30  8:08                                                           ` Eli Zaretskii
2023-12-30  9:50                                                             ` Eli Zaretskii
2023-12-30 10:10                                                               ` Eli Zaretskii
2023-12-30 10:39                                                                 ` Ihor Radchenko
2023-12-30 11:07                                                                   ` Eli Zaretskii
2023-12-30 12:51                                                             ` Ihor Radchenko
2023-12-30 13:24                                                               ` Eli Zaretskii
2024-01-01 17:11                                                               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-22 13:02         ` Dmitry Gutov
2023-09-22 13:10           ` Eli Zaretskii
2023-09-22 13:38           ` Ihor Radchenko
2023-09-22 13:45             ` Dmitry Gutov
2023-10-04 10:58   ` Ihor Radchenko
2023-10-04 11:46     ` Dmitry Gutov
2023-10-05 11:27       ` Ihor Radchenko
2023-10-05 17:14         ` Dmitry Gutov

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=83zg1d468w.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=66117@debbugs.gnu.org \
    --cc=dmitry@gutov.dev \
    --cc=yantar92@posteo.net \
    /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.