bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13539: Use fdopendir, fstatat and readlinkat, for efficiency.


From: Eli Zaretskii
Subject: bug#13539: Use fdopendir, fstatat and readlinkat, for efficiency.
Date: Thu, 24 Jan 2013 19:28:33 +0200

> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]