GNU bug report logs - #66117
30.0.50; `find-buffer-visiting' is slow when opening large number of buffers

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> posteo.net>

Date: Wed, 20 Sep 2023 08:53:02 UTC

Severity: minor

Found in version 30.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> posteo.net>
Cc: dmitry <at> gutov.dev, 66117 <at> debbugs.gnu.org
Subject: bug#66117: 30.0.50; `find-buffer-visiting' is slow when opening large number of buffers
Date: Sat, 07 Oct 2023 13:57:14 +0300
> From: Ihor Radchenko <yantar92 <at> posteo.net>
> Cc: dmitry <at> gutov.dev, 66117 <at> debbugs.gnu.org
> Date: Sat, 07 Oct 2023 09:29:15 +0000
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > From my POV, there are two alternatives here:
> >
> >   . expose several new primitives to Lisp to make find-buffer-visiting
> >     faster without changing the way we store the file-to-buffer
> >     association information
> >   . introduce caches or change the way file-to-buffer associations are
> >     stored to speed up find-buffer-visiting
> >
> > What I'd like to see is that someone implements the first idea, and
> > times find-buffer-visiting after that to see if it becomes fast
> > enough.  Then we can discuss whether anything else is needed.
> 
> Agree. That's what I was trying to do. However, one of the new primitives
> will require searching a buffer with given value of `buffer-file-number'
> - the variable not defined in C.

buffer-file-number is defined as follows:

		    (file-attribute-file-identifier
                     (file-attributes buffer-file-name)))

whereas file-attribute-file-identifier is

  (defsubst file-attribute-file-identifier (attributes)
    "The inode and device numbers in ATTRIBUTES returned by `file-attributes'.
  The value is a list of the form (INODENUM DEVICE), where DEVICE could be
  either a single number or a cons cell of two numbers.
  This tuple of numbers uniquely identifies the file."
    (nthcdr 10 attributes))

So in C this is:

  list2 (INT_TO_INTEGER (s.st_ino), INT_TO_INTEGER (s.st_dev));

> >> For example, org-element.el needs to set buffer-local values in base
> >> buffer of an indirect buffer every time buffer text is being edited.
> >
> > And that is performance-critical? in what way and in which situations?
> 
> When making a large number of edits in Org buffer. The code I am
> referring to runs in `after-change-functions' and therefore should be as
> fast as possible.

I'd need to see measurements for that.  In any case, this is a
separate issue.




This bug report was last modified 1 year and 135 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.