unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Mendler via "Emacs development discussions." <emacs-devel@gnu.org>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: Michael Heerdegen via "Emacs development discussions."
	<emacs-devel@gnu.org>
Subject: Re: Add a function for building sort predicates
Date: Thu, 01 Feb 2024 21:19:25 +0100	[thread overview]
Message-ID: <875xz89bua.fsf@daniel-mendler.de> (raw)
In-Reply-To: <87eddwuh0m.fsf@web.de> (Michael Heerdegen's message of "Thu, 01 Feb 2024 20:22:01 +0100")

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Daniel Mendler <mail@daniel-mendler.de> writes:
>
>> Did you perform some measurements, comparing with the hand-written
>> predicate in package.el?  The code does not look efficient with the
>> function calls and the throws.
>
> My version was around 6% slower. Using dynamic lookup of the key order.
> I did not try with native compiling.

Would be interesting to see the results with native compilation. I will
try it when I find time.

>> In contrast, if the macro creates a sequence of conditions the native
>> compiler can optimize the result. It all depends on the use case. If
>> the rules are supposed to be customizable and the lists are short, the
>> dynamic approach will likely work well enough. For long lists an
>> efficient sort predicate makes a difference in my experience, e.g., in
>> a dynamically updating completion UI with thousands of candidates,
>> since the predicate is called very often.
>
> A disadvantage is that custom option will have to introduce new :set
> dependencies, I wanted to avoid that.

What do you mean by :set dependencies? If we use a macro, customization
is not possible anymore. So if customization of the rules is a
requirement, then we have to go with a function. Another optimization
option is to transparently compile to byte code. Iirc such an approach
was discussed for `buffer-match-p'.

> But in some cases the speed difference might be worth such an
> optimization.  If you want to experiment, please be my guest.

Yes. The question is where this predicate builder is supposed to be
used. Probably interfaces like list-packages or generally tabulated-list
buffers would not profit so much from optimization. With ELPA and MELPA
the packages buffer has around 6000 entries.

Daniel



  reply	other threads:[~2024-02-01 20:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 17:06 Add a function for building sort predicates Michael Heerdegen
2024-02-01 17:19 ` Daniel Mendler via Emacs development discussions.
2024-02-01 17:26   ` Eli Zaretskii
2024-02-01 18:10     ` Michael Heerdegen via Emacs development discussions.
2024-02-01 19:09       ` Eli Zaretskii
2024-02-02 20:11         ` Michael Heerdegen
2024-02-03  2:55           ` Emanuel Berg
2024-02-03  7:08           ` Eli Zaretskii
2024-02-03 10:35             ` Michael Heerdegen
2024-02-01 18:04   ` Michael Heerdegen via Emacs development discussions.
2024-02-01 18:23     ` Daniel Mendler via Emacs development discussions.
2024-02-01 19:22       ` Michael Heerdegen
2024-02-01 20:19         ` Daniel Mendler via Emacs development discussions. [this message]
2024-02-01 22:48 ` [External] : " Drew Adams
2024-02-02 20:05   ` Michael Heerdegen
2024-02-02 22:30     ` Drew Adams

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875xz89bua.fsf@daniel-mendler.de \
    --to=emacs-devel@gnu.org \
    --cc=mail@daniel-mendler.de \
    --cc=michael_heerdegen@web.de \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).