unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Lin Sun <sunlin7.mail@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>,
	acorallo@gnu.org, 41646@debbugs.gnu.org, stefankangas@gmail.com,
	monnier@gnu.org
Subject: bug#41646: Startup in Windows is very slow when load-path contains many
Date: Mon, 21 Oct 2024 10:34:24 -0400	[thread overview]
Message-ID: <jwvmsix4ld1.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CABCREdqJP3s1XGfdTGPC=tVuNgjjM9ENzkb5pajNe3U3mRXezA@mail.gmail.com> (Lin Sun's message of "Mon, 21 Oct 2024 04:09:25 +0000")

> The `load-hints` can reduce searching attempts by putting the matched
> paths on the top of `load-path`, it won't break the original
> load-path; and the patch for the `package.el` will put the installed
> files into the `load-hints`.

The downside is that it can break existing setups for users who use
`package.el` but also modify their `load-path` "by hand" in the
init file, and it doesn't help users who don't use `package.el`.

Note also that your `load-hints` could grow large, so scanning it could
take a significant amount of time.  Maybe it would make sense to turn it
into a hash table for those entries that don't use the "*" special
thingy (and maybe use a radix-tree for those entries using the "*"
special thingy)?

But your prefix idea makes me think maybe we can aim for a significantly
smaller table, where we basically record only one entry per
package/directory, like for "~/.emacs.d/elpa/helm-core-VERSION/" we just
record "helm" because all the `.el` files share the "helm" prefix.
I.e. keep for each dir the corresponding longest-common-prefix.
If we're careful to consider only those files with a `.el` suffix, then
I think we can reduce the hint to such a longest-common-prefix.  I.e. an
info which doesn't say just "you can find FOO* files here" but "you can
find *only* FOO* files here".

Then we should be able to create quickly (so it can be recomputed on the
fly whenever `load-path` changes) a radix-tree that maps a relative
file name to the list of directories from `load-path` where it is
worthwhile to look (by filtering out those dirs whose
longest-common-prefix doesn't match).  We'd only do it for MUST_SUFFIX
is specified, of course.

> 1. On my local linux test env, disable load-hints on the package.el,
> the test cli spends 6.327s; and enable load-hints then it spends
> 5.392s.
>
> 2. On my local Windows test env, disable load-hints on the package.el,
> the test cli spends 11.769s, and enable load-hints then it spends
> 7.279s.

Is that with or without using `package-quickstart`?

BTW, in your patch, you change `locate-file-internal` which seems wrong,
since that function is not specific to loading ELisp files, it's also
used for $MANPATH, $PATH, and things like that.

Similarly, I wasn't able to convince myself that your patch does the
right thing when `require` or `load` is used such that MUST_SUFFIX is
not specified.


        Stefan






  reply	other threads:[~2024-10-21 14:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CABCREdrcJL1xfhB4NFW-WWRDd2ucMj_rVRTGZw1FqLHJHJFaQg@mail.gmail.com>
     [not found] ` <86jzedy84g.fsf@gnu.org>
     [not found]   ` <CABCREdq4JXaJbQwsS9=MWEzYnOAr2CZCCvg6pjjyNEgZO-MZrg@mail.gmail.com>
     [not found]     ` <CABCREdosvZSGgwrU8bvVtCzK+P0aX3ACCeTDqQXyg+6xhFXzkw@mail.gmail.com>
     [not found]       ` <86r08luqsq.fsf@gnu.org>
     [not found]         ` <CABCREdqtUisaCsV4=-nc7wNJ3P5Z_43yPXrYH1ZwWPGOQuptsw@mail.gmail.com>
     [not found]           ` <86frp1unvu.fsf@gnu.org>
     [not found]             ` <CABCREdp2Ug_wgnj=w=bS-XiYESp6D4Cr4aE2G2wBHTwAttZ=9Q@mail.gmail.com>
     [not found]               ` <86y12stv24.fsf@gnu.org>
     [not found]                 ` <CABCREdogicz4OKd0ORAtD_u2Q9HdLSt+DFs9pTqUQ1gcWGFdYg@mail.gmail.com>
2024-10-13  9:50                   ` bug#41646: Startup in Windows is very slow when load-path contains many Stefan Kangas
2024-10-13 10:43                     ` Eli Zaretskii
2024-10-13 14:47                       ` Lin Sun
2024-10-13 15:24                         ` Eli Zaretskii
2024-10-13 15:43                           ` Lin Sun
2024-10-13 15:56                             ` Eli Zaretskii
2024-10-13 16:03                               ` Lin Sun
2024-10-13 16:39                                 ` Eli Zaretskii
2024-10-16  7:51                                   ` Lin Sun
2024-10-21  4:09                                     ` Lin Sun
2024-10-21 14:34                                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-10-21 17:11                                         ` Lin Sun
2024-10-21 19:53                                         ` Lin Sun
2024-10-13 15:51                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=jwvmsix4ld1.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=41646@debbugs.gnu.org \
    --cc=acorallo@gnu.org \
    --cc=eliz@gnu.org \
    --cc=monnier@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=stefankangas@gmail.com \
    --cc=sunlin7.mail@gmail.com \
    /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).