unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Arthur Miller <arthur.miller@live.com>
Cc: emacs-devel@gnu.org
Subject: Re: 28.0.50; Proposal: slightly more efficient package-quickstart.el
Date: Tue, 20 Jul 2021 11:49:32 -0400	[thread overview]
Message-ID: <jwv35s957oh.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <AM9PR09MB497759E697387E6589CE558896E29@AM9PR09MB4977.eurprd09.prod.outlook.com> (Arthur Miller's message of "Tue, 20 Jul 2021 08:01:03 +0200")

> Not so much, but it is not so much about noticable difference, more
> about not performing unnecessary computation.

But Emacs is more often limited by manpower than CPU, so the impact on
code complexity should not be discounted.

> As the loop progresses, for every dir N, the loop does N-1 path
> comparisons. These are unnecessary comparisons since when we know for
> sure that the string is not added yet. Trend in Emacs seems to go
> towards having more and more packages installed. This removes
> N(N-1)) comparisons.

I know.  But you have to get to a list of at least 2000 elements
before this N² starts making a noticable (0.2s) difference [tested on
an old 1GHz Cortex-A8.  ]

By the time the user has 2000 packages installed, there are several
other performance problems that will be more noticeable, I'm afraid.
E.g. the length of `load-path` itself will be a source of slowdown.

I know 200 packages is fairly common nowadays, so 1000 or more in not an
outlandish idea, and there are indeed performance issues that come up
when we have many packages, but I suspect that we'll need more thorough
changes to tackle this, and in any case it should be driven by concrete
measurements, otherwise we'll waste our time optimizing details that
don't actually matter.

>> Beside the hypothetical risk that the regexp matches an `add-to-list` to
>> an unrelated variable, I think this risks introducing real bugs for
>> packages which use (add-to-list 'load-path <subdir>) to add
>> *sub*directories.
> Yes, I was aware of it, but I am not sure how to write the regex, to
> avoid that risk.

I don't think you can avoid that problem by fixing the regexp, but
rather by `read`ing the sexp and looking at the directory it adds to
make sure it is indeed one of the ones you're adding "by hand".

Or maybe a better approach is to do something like what we do with
`Info-directory-list`, tho it might also be tricky to "get it right".

>> Of course, we can fix those problems, but unless there's a compelling
>> performance argument, I think it's a waste of time.
> It's quite simple to do,

It's not if you want to handle correctly the corner cases, as this email
discussion shows.

> I don't know, at least in theory :).

Maybe there's a theoretical gain.  But there's a very real practical
loss in time spent getting the code to work correctly and maintaining it
in the future.


        Stefan




  reply	other threads:[~2021-07-20 15:49 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-20  0:27 28.0.50; Proposal: slightly more efficient package-quickstart.el Arthur Miller
2021-07-20  2:54 ` Stefan Monnier
2021-07-20  6:01   ` Arthur Miller
2021-07-20 15:49     ` Stefan Monnier [this message]
2021-07-22 22:38       ` Arthur Miller
2021-07-23 14:36         ` Stefan Monnier
2021-07-23 14:50           ` Async rebuild package-quickstart after packages update? was " T.V Raman
2021-08-03 22:20             ` Stefan Monnier
2021-08-04  2:24               ` T.V Raman
2021-08-04  3:25                 ` Stefan Monnier
2021-08-04 14:20                   ` T.V Raman
2021-08-04 17:19                     ` Stefan Monnier
2021-08-04 18:36                       ` T.V Raman
2021-08-05  0:22                       ` T.V Raman
2021-08-05  6:00                         ` Eli Zaretskii
2021-08-05 14:17                           ` T.V Raman
2021-08-05 14:29                           ` T.V Raman
2021-08-05 14:59                             ` Stefan Monnier
2021-08-05 15:21                               ` T.V Raman
2021-08-05 16:23                                 ` Stefan Monnier
2021-08-06  5:18                                   ` Arthur Miller
2021-08-06  6:39                                     ` Eli Zaretskii
2021-08-06 13:20                                       ` Arthur Miller
2021-08-06 13:28                                         ` Eli Zaretskii
2021-08-06 14:13                                           ` Arthur Miller
2021-08-06 14:53                                           ` Arthur Miller
2021-08-07  0:46                                             ` chad
2021-08-07  5:26                                               ` Eli Zaretskii
2021-08-07  5:45                                               ` Arthur Miller
2021-08-06 14:24                                       ` Stefan Monnier
2021-08-06 14:29                                         ` T.V Raman
2021-08-05 16:25                                 ` Eli Zaretskii
2021-08-05 16:57                                   ` T.V Raman
2021-08-05 17:03                                     ` Eli Zaretskii
2021-08-05 18:11                                     ` Stefan Monnier
2021-08-05 18:23                                       ` T.V Raman
2021-08-05 19:48                                       ` On The Use(fullness) of make-thread " T.V Raman
2021-08-06  5:24                                       ` Arthur Miller
2021-08-07  4:19                                       ` Clément Pit-Claudel
2021-08-07  5:38                                         ` Arthur Miller
2021-07-23 17:00           ` Arthur Miller
2021-07-23 22:26       ` Arthur Miller
2021-07-23 22:37         ` Arthur Miller

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=jwv35s957oh.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=arthur.miller@live.com \
    --cc=emacs-devel@gnu.org \
    /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).