unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Nicolas Bértolo" <nicolasbertolo@gmail.com>
To: 41646@debbugs.gnu.org
Subject: bug#41646: Startup in Windows is very slow when load-path contains many entries.
Date: Mon, 1 Jun 2020 11:26:35 -0300	[thread overview]
Message-ID: <CAFnS-O=GE8k8HMMU0eSzFmvQq2CsuLXBgTv8EVzHe3eraivnzw@mail.gmail.com> (raw)

I have an issue regarding startup times in Windows. My configuration is
Spacemacs with many layers enabled. My load-path contains 380 entries.

I have profiled Emacs in Windows and found that it spends most of the startup
time calling wopen(). This is because when calling (load "foo") it checks all
directories in load-path for ("foo.el" "foo.elc" "foo.el.gz" "foo.elc.gz"
"foo.dll"). It gets worse when load-prefer-newer is t.

In my case `load-path` contains 380 entries, so every call to load will perform
380 * 5 = 1900 calls to wopen. This is very slow in Windows because its
filesystem is not optimized for so many accesses to small files.

I thought that a caching mechanism would help.

This "cache" would consist of a mapping of files that would get probed when
(load "foo") runs. It would be implemented as a hash table. The contents of this
hash table could be loaded from load-cache.el files in each package directory.

The directory foo-pkg could have a file load-cache.el with:

foo -> ("foo-pkg/foo.el"
        "foo-pkg/foo.elc")
[...]

The directory bar-pkg could have a file load-cache.el with:

bar -> ("bar-pkg/bar.el"
        "bar-pkg/bar.elc")
[...]

When a package is activated we could update the in-memory hash table by loading
its load-cache.el file. Then, when (require 'foo) runs, the loading code could
look at the hash table and only fopen() the files associated with the feature we
are loading. This would reduce the number of calls to fopen() from thousands to
~2 in the worst case.

Or we could have a big load-cache.el in `package-user-dir'. I prefer many small
files because maintaining the big file when many Emacs instances could be
installing or removing packages is synchronization nightmare.

Of course, this feature would be disabled by default.

What do you think?

Nicolas





             reply	other threads:[~2020-06-01 14:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-01 14:26 Nicolas Bértolo [this message]
2020-06-01 16:05 ` bug#41646: Startup in Windows is very slow when load-path contains many entries Eli Zaretskii
2020-06-01 16:46   ` Nicolas Bértolo
2020-06-01 17:17     ` Eli Zaretskii
2020-06-01 19:51       ` Nicolas Bértolo
2020-06-02  2:17         ` Eli Zaretskii
2020-06-03  1:07           ` Nicolas Bértolo
2020-08-14 17:22             ` Lars Ingebrigtsen
2020-08-14 19:07               ` Eli Zaretskii
2021-05-13  9:17                 ` Lars Ingebrigtsen
2021-05-13 10:20                   ` Eli Zaretskii
2021-05-13 11:31                     ` Lars Ingebrigtsen

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='CAFnS-O=GE8k8HMMU0eSzFmvQq2CsuLXBgTv8EVzHe3eraivnzw@mail.gmail.com' \
    --to=nicolasbertolo@gmail.com \
    --cc=41646@debbugs.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).