GNU bug report logs -
#66117
30.0.50; `find-buffer-visiting' is slow when opening large number of buffers
Previous Next
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
Eli Zaretskii <eliz <at> gnu.org> writes:
>> What do you think about introducing something like
>>
>> struct buffer buffer_overrides;
>>
>> It will be similar to buffer_defaults in buffer.c, but will hold the
>> overriding values of buffer-local variables that are to be used instead
>> of proper buffer-local variables. That way, we can speed up let-binding
>> of case-fold-search.
>
> I'm sorry, I don't think I understand how this will work and avoid the
> problems we have with let-binding. So I added Stefan, in the hope
> that he might understand what I am evidently missing.
Let me elaborate.
- In eval.c, `Flet' always uses `specbind' to bind `case-fold-search'.
Because `case-fold-search' is declared special (u.s.declared_special =
true).
- For `case-fold-search', `specbind' does
/* If SYMBOL is a per-buffer variable which doesn't have a
buffer-local value here, make the `let' change the global
value by changing the value of SYMBOL in all buffers not
having their own value. This is consistent with what
happens with other buffer-local variables. */
if (NILP (Flocal_variable_p (symbol, Qnil)))
specpdl_ptr->let.kind = SPECPDL_LET_DEFAULT;
- Later, `specbind' calls `do_specbind' where SPECPDL_LET_DEFAULT causes
a call to `set_default_internal'.
- Then, `set_default_internal', for any variable with positive
buffer_local_flags loops over all the live buffers to overwrite the
buffer-local value.
This loop is the bottleneck, making let-binding
of `case-fold-search' (and any other variable marked in buffer.c:4691
block) scale with the number of open buffers.
- What I propose is to avoid this loop in `do_specbind' altogether.
Instead of having to loop through all the buffers to set temporary
buffer-local value, I propose to introduce special buffer object
`buffer_overrides' that will hold such temporary bindings.
Then, we can change BVAR to something like
#define BVAR(buf, field) (buffer_overrides->field ## _ == UNSET ?\
(buf)->field ## _ :\
buffer_overrides->field ## _)
and replace the loop with simply setting buffer_overrides slot.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
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.