emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should `get-file-buffer' be implemented in Elisp?


From: Eli Zaretskii
Subject: Re: Should `get-file-buffer' be implemented in Elisp?
Date: Mon, 17 Jul 2023 16:11:33 +0300

> From: Ihor Radchenko <yantar92@posteo.net>
> Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
> Date: Mon, 17 Jul 2023 09:28:50 +0000
> 
> <tomas@tuxteam.de> writes:
> 
> > On Sun, Jul 16, 2023 at 08:19:10PM +0000, Ihor Radchenko wrote:
> >
> > [...]
> >
> >> scenarios. And in general lookup as well as hash tables start to
> >> outperform alists just at 20-30 elements [1]
> >
> > For me, it's more like 45-ish:
> 
> Right. The link I provided actually also mentions similar number.
> 
> > How many people around here have regularly 1000 buffers?
> 
> Well. Check out https://github.com/org-roam/org-roam
> People routinely deal with thousands of buffers there and complain about
> that.
> 
> I also did a benchmark for opening several thousands of files in Emacs
> and the performance was quite disappointing. (Though, admittedly, not
> because of `get-file-buffer').
> 
> > And even at 100, the absolute time is rather negligible. Somewhere
> > near 5000 buffers my (not very fast) machine reaches the 100ms
> > area for alists and lingers in the 2ms area for hashes (that would
> > be where I'd start worrying).
> 
> 100ms is fast when you do it once. But `get-file-buffer' may be called
> rather frequently by `with-temp-buffer'. 

Performance improvement when there are many buffers is indeed a worthy
goal, but if we want to make get-file-buffer as fast as possible,
leaving it in C makes more sense.  We can call hash-table functions
from C as well; moreover, we can call them in a more efficient way,
bypassing validity checks that primitives often perform on their
arguments.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]