From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#13539: Use fdopendir, fstatat and readlinkat, for efficiency. Date: Thu, 24 Jan 2013 19:28:33 +0200 Message-ID: <83vcamlcce.fsf@gnu.org> References: <5100F04A.1020603@cs.ucla.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1359048620 27695 80.91.229.3 (24 Jan 2013 17:30:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 24 Jan 2013 17:30:20 +0000 (UTC) Cc: 13539@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 24 18:30:37 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TyQdC-0000w6-Iq for geb-bug-gnu-emacs@m.gmane.org; Thu, 24 Jan 2013 18:30:30 +0100 Original-Received: from localhost ([::1]:33624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyQcs-0001df-WF for geb-bug-gnu-emacs@m.gmane.org; Thu, 24 Jan 2013 12:30:11 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:49262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyQcm-0001Yp-Up for bug-gnu-emacs@gnu.org; Thu, 24 Jan 2013 12:30:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TyQch-0006gX-9t for bug-gnu-emacs@gnu.org; Thu, 24 Jan 2013 12:30:02 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42625) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyQch-0006gQ-6f for bug-gnu-emacs@gnu.org; Thu, 24 Jan 2013 12:29:59 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TyQck-0000g6-Bk for bug-gnu-emacs@gnu.org; Thu, 24 Jan 2013 12:30:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 24 Jan 2013 17:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13539 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 13539-submit@debbugs.gnu.org id=B13539.13590485542526 (code B ref 13539); Thu, 24 Jan 2013 17:30:02 +0000 Original-Received: (at 13539) by debbugs.gnu.org; 24 Jan 2013 17:29:14 +0000 Original-Received: from localhost ([127.0.0.1]:48089 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TyQby-0000eg-6o for submit@debbugs.gnu.org; Thu, 24 Jan 2013 12:29:14 -0500 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:54746) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TyQbv-0000eU-PM for 13539@debbugs.gnu.org; Thu, 24 Jan 2013 12:29:13 -0500 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0MH5002004J52P00@a-mtaout20.012.net.il> for 13539@debbugs.gnu.org; Thu, 24 Jan 2013 19:28:29 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MH50011F4JGK3C0@a-mtaout20.012.net.il>; Thu, 24 Jan 2013 19:28:29 +0200 (IST) In-reply-to: <5100F04A.1020603@cs.ucla.edu> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:70245 Archived-At: > Date: Thu, 24 Jan 2013 00:26:50 -0800 > From: Paul Eggert > CC: Eli Zaretskii > > 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.