unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: 13539@debbugs.gnu.org
Subject: bug#13539: Use fdopendir, fstatat and readlinkat, for efficiency.
Date: Thu, 24 Jan 2013 19:28:33 +0200	[thread overview]
Message-ID: <83vcamlcce.fsf@gnu.org> (raw)
In-Reply-To: <5100F04A.1020603@cs.ucla.edu>

> Date: Thu, 24 Jan 2013 00:26:50 -0800
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: Eli Zaretskii <eliz@gnu.org>
> 
> Attached is a patch that can greatly improve the performance of
> directory-files-and-attributes, which I'd like to install
> into the trunk.  The key idea is to use fstatat
> instead of lstat; this reduces directory-reading
> from an O(ND) to an O(N) operation, where N is the number
> of directory entries and D is the length of
> the directory's name.

Is it really worth our while to spend energy on speeding up an API
that goes mostly unused in Emacs?  Its only heavy user is ls-lisp.el,
which is used on Windows to replace ls in Dired.  But the Windows
build will not be able to benefit from these changes anyway.  Just a
thought...

> This patch works on POSIXish hosts, but it'll no doubt
> need a few changes to the MS-Windows makefiles to compile
> fdopendir.c, fstatat.c, openat-die.c, save-cwd.c, openat-proc.c,
> or whatever subset of these is needed on MS-Windows.
> I'll CC: this to Eli to give him a heads-up.

I'm sorry, but this changeset is extremely unfriendly to the Windows
build.  It relies on the ability to open a directory, which is not
supported by 'open' on Windows; it uses the gnulib dirent replacement,
which is incompatible with the existing implementation in Emacs; it
uses sys/stat.h header and functions in ways that are incompatible
with their replacements in Emacs; and it requires to process many
header files with Sed, which was not required to build Emacs on
Windows until now.  All that to eventually fall back on opendir and
stat/lstat, since the *at functionality cannot be supported on Windows
anyway.  Fixing all this would require a lot of work for absolutely no
gain, which sounds like a waste of energy.

Instead, I suggest to use in dired.c functions that will accept both a
file name and a file descriptor, so that Posix hosts could use the
descriptor and ignore the file name, while on Windows Emacs will
ignore the descriptor and use the file name.  (This requires to retain
the code you suggest to delete that concatenates file names returned
by readdir with the parent directory; we could have that code
#ifdef'ed away for Posix hosts.)  That will still require some
adjustments in the w32 sources, but they will be 2 orders of magnitude
smaller and less complex, and will not hamper Posix hosts in any way.
The only downside will be somewhat more ugly code, but files like
dired.c already have quite a few #ifdef's, not surprisingly.

Thanks.





  reply	other threads:[~2013-01-24 17:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-24  8:26 bug#13539: Use fdopendir, fstatat and readlinkat, for efficiency Paul Eggert
2013-01-24 17:28 ` Eli Zaretskii [this message]
2013-01-28  8:34   ` Paul Eggert
2013-01-28 14:37     ` Eli Zaretskii
2013-01-30  0:56       ` Paul Eggert
2013-01-30 17:27         ` Eli Zaretskii
2013-02-01  6:42           ` Paul Eggert
2013-01-30 19:24         ` Stefan Monnier
2013-01-30 20:24           ` Eli Zaretskii

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=83vcamlcce.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=13539@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    /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).