[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ido-switch-buffer is slow with many buffers; others are fast
From: |
Spencer Baugh |
Subject: |
Re: ido-switch-buffer is slow with many buffers; others are fast |
Date: |
Sun, 15 Nov 2020 15:49:06 -0500 |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> The associated bug#41029 mentions:
>>> Many of the buffer locals (in particular I think it's the
>>> SYMBOL_FORWARDED types --- my terminoly may be off), appear to be O(n)
>>> to bind, where n is the number of live buffers.
>> That's quite worrying - that implies that pretty much any code will run
>> slower as the number of buffers increases, even if it doesn't have
>> anything to do with buffers!
>
> Yup.
> It affects all the vars defined via `DEFVAR_PER_BUFFER`.
>
>> This explains the slow performance of let-binding case-fold-search
>> that I mentioned in another branch of this thread.
>
> Yes it's the source of that problem.
>
>> Is this poor scaling of binding buffer locals a known problem?
>
> At least since bug#41029, yes ;-)
>
>> Has anyone worked on fixing this?
>
> Not that I know, no.
>
> It's a fairly tricky part of the code, but if you're interested, I'd be
> very happy to help you along (I'm familiar with this code for having
> reworked it somewhat around the time of Emacs-24).
I'm not sure I have the requisite expertise, but I have the motivation,
so yes, I'll give fixing this a try.
If I'm guessing right, the problem is the NILP (Flocal_variable_p
(symbol, Qnil)) case of specbind, on line 3351 of eval.c. In that case,
the let-binding actually changes the "global" value of the variable.
So in turn, we call do_specbind, which calls set_default_internal, which
iterates over all buffers to set the buffer slot to the "global"
value. And then I guess we again reset the value in all live buffers
when unwinding the let?
(Actually, couldn't this be buggy if a new live buffer is created while
in the scope of the let? The new live buffer wouldn't have the value set
by the let-binding...)
It seems like maybe this could be fixed by having a true global value
for DEFVAR_PER_BUFFER which is checked on variable read when there's no
buffer-local binding. Then a let-binding which changes the "global"
value would just, change that value. I'm not sure why it doesn't already
work like that?
I added arnold@tdrhq.com to CC since they filed bug#41029 in the first
place. Arnold - you mentioned trying to optimize the binding process in
the bug. Do you have any more detail about what you tried that didn't
work out?
- ido-switch-buffer is slow with many buffers; others are fast, catern, 2020/11/14
- Re: ido-switch-buffer is slow with many buffers; others are fast, Stefan Monnier, 2020/11/14
- Re: ido-switch-buffer is slow with many buffers; others are fast, Dmitry Gutov, 2020/11/14
- Re: ido-switch-buffer is slow with many buffers; others are fast, Spencer Baugh, 2020/11/14
- Re: ido-switch-buffer is slow with many buffers; others are fast, Stefan Monnier, 2020/11/15
- Re: ido-switch-buffer is slow with many buffers; others are fast,
Spencer Baugh <=
- Re: ido-switch-buffer is slow with many buffers; others are fast, Arnold Noronha, 2020/11/15
- [PATCH 02/10] Add bset_save_length and use it, Spencer Baugh, 2020/11/19
- [PATCH 04/10] Use bset_enable_multibyte_characters everywhere, Spencer Baugh, 2020/11/19
- [PATCH 00/10] Speeding up DEFVAR_PER_BUFFER (Was: ido-switch-buffer is slow), Spencer Baugh, 2020/11/19
- Re: [PATCH 00/10] Speeding up DEFVAR_PER_BUFFER, Stefan Monnier, 2020/11/19
- [PATCH v2 00/16] Speeding up DEFVAR_PER_BUFFER, Spencer Baugh, 2020/11/21
- [PATCH v2 01/16] Add a test for let-binding unwinding, Spencer Baugh, 2020/11/21
- Re: [PATCH v2 01/16] Add a test for let-binding unwinding, Stefan Monnier, 2020/11/25
- Re: [PATCH v2 01/16] Add a test for let-binding unwinding, Spencer Baugh, 2020/11/30
- [PATCH v2 05/16] Add BVAR_DEFAULT for access to buffer defaults, Spencer Baugh, 2020/11/21