unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Eric M. Ludlam" <eric@siege-engine.com>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: Emacs Development <emacs-devel@gnu.org>
Subject: Re: Project systems (again)
Date: Sat, 19 Apr 2014 15:37:18 -0400	[thread overview]
Message-ID: <5352D06E.7000403@siege-engine.com> (raw)
In-Reply-To: <jwvwqeltn45.fsf-monnier+emacs@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1582 bytes --]

On 04/19/2014 10:26 AM, Stefan Monnier wrote:
>> When support for projects of that nature were added, what I quickly found
>> was that walking up the directory tree searching for them really hammered
>> the auto-mounter on networked file systems.
>
> Currently, we walk up the tree several times per find-file for VC's
> backend detection.  So this is a "solved" problem (use
> locate-dominating-file, which should really be named
> locate-dominating-dir, but it's not worth the trouble renaming it).

Thanks Stefan,

I'd only heard of this function recently, and was unsure if it was 
appropriate for EDE.   In particular, I see in reading the code that it 
tries to avoid searching for files around root, above home directories, 
and matching a particular regexp, so that is good.

I tried some timing tests with it in my CEDET repository (4 deep 
directory) looping 100 times to see how it competes.

Detect detect-with-ldf took 0.0166 seconds
Detect detect-with-ldf-ede-simple took 0.0442 seconds
Detect detect-with-ldf-ede-full took 0.2112 seconds

Detect detect-with-ede took 0.0000 seconds
Detect detect-with-ede-file-detect took 0.0016 seconds
Detect detect-with-ede-no-buffer-cache took 0.1612 seconds
Detect detect-with-ede-buffer-init-hook took 0.2805 seconds

See attached code for details.

It did pretty well considering the added feature.

There are some strange hacks in the EDE autoloader due to not navigating 
up a directory tree.  I'll see if I can take advantage of this function 
and simplify & enhance some of EDE's detection: the last 2 above timings.

Eric

[-- Attachment #2: tpdm.el --]
[-- Type: text/x-emacs-lisp, Size: 3188 bytes --]

;; Test speeds of different project detect machanisms.

(require 'ede)

(defun find-ede-proj-with-ldf-predicate (ldf-file)
  "Predicate for finding EDE projects with `locate-dominating-file'.
Argument LDF-FILE is the current directory file from LDF."
  (let ((types ede-project-class-files)
	(ret nil))
    ;; Loop over all types, loading in the first type that we find.
    (while (and types (not ret))
      (if (ede-dir-to-projectfile-simple (car types) ldf-file)
	  (progn
	    ;; We found one!  Require it now since we will need it.
	    ;;(require (oref (car types) file))
	    (setq ret (car types)))
	(setq types (cdr types))))
    ret))

(defmethod ede-dir-to-projectfile-simple ((this ede-project-autoload) dir)
  "Simplified version of `ede-dir-to-projectfile'."
    (let* ((d (file-name-as-directory dir))
	   (pf (oref this proj-file))
	   (f (when (stringp pf) (expand-file-name pf (or root d))))
	   )
      (when (and f (file-exists-p f))
	f)))

(defun find-ede-proj-with-ldf-predicate-full (ldf-file)
  "Predicate for finding EDE projects with `locate-dominating-file'.
Argument LDF-FILE is the current directory file from LDF."
  (let ((types ede-project-class-files)
	(ret nil))
    ;; Loop over all types, loading in the first type that we find.
    (while (and types (not ret))
      (if (ede-dir-to-projectfile (car types) ldf-file)
	  (progn
	    ;; We found one!  Require it now since we will need it.
	    ;;(require (oref (car types) file))
	    (setq ret (car types)))
	(setq types (cdr types))))
    ret))

(defun detect-with-ldf ()
  "Detect using `locate-dominating-file'."
  (locate-dominating-file (buffer-file-name) "INSTALL"))

(defun detect-with-ldf-ede-simple ()
  "Detect using `locate-dominating-file' using a simplifed EDE predicate."
  (locate-dominating-file (buffer-file-name) 'find-ede-proj-with-ldf-predicate))

(defun detect-with-ldf-ede-full ()
  "Detect using `locate-dominating-file' using an EDE predicate."
  (locate-dominating-file (buffer-file-name) 'find-ede-proj-with-ldf-predicate-full))

(defun detect-with-ede ()
  "Detect using EDE's project detector."
  (ede-current-project))

(defun detect-with-ede-file-detect ()
  "Detect using EDE's file based project detector."
  (ede-directory-project-p default-directory))

(defun detect-with-ede-no-buffer-cache ()
  "Detect using EDE's file detect that uses no buffer cache info."
  (ede-directory-get-open-project default-directory 'ROOT))

(defun detect-with-ede-buffer-init-hook ()
  "Detect using EDE's buffer initialization hook."
  (ede-initialize-state-current-buffer))
  ;(ede-toplevel-project default-directory))

(defun detection-speed ()
  "Try out different detection schemes."
  (interactive)
  (dolist (DM '(detect-with-ldf
		detect-with-ldf-ede-simple
		detect-with-ldf-ede-full
		detect-with-ede
		detect-with-ede-file-detect
		detect-with-ede-no-buffer-cache
		detect-with-ede-buffer-init-hook
		))
    (let* ((start (current-time))
	   (index 100)
	   (out
	    (while (> index 0)
	      (funcall DM)
	      (setq index (1- index))))
	   (end (current-time)))
      (message "Detect %S took %.4f seconds"
	       DM
	       (float-time (time-subtract end start))))))

  reply	other threads:[~2014-04-19 19:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-17 21:52 Project systems (again) Daniel Colascione
2014-04-18  6:37 ` Eli Zaretskii
2014-04-18  7:07   ` Daniel Colascione
2014-04-18  7:50     ` Eli Zaretskii
2014-04-18  7:58       ` Daniel Colascione
2014-04-18  8:49         ` Eli Zaretskii
2014-04-19  1:45         ` Eric M. Ludlam
2014-04-19 14:26           ` Stefan Monnier
2014-04-19 19:37             ` Eric M. Ludlam [this message]
2014-04-18 15:52     ` Stefan Monnier
2014-04-18 18:37     ` Alex Ott
2014-04-18 14:03   ` Dmitry Gutov
2014-04-19  8:55     ` Bozhidar Batsov
2014-04-19 14:28       ` Stefan Monnier
2014-04-19 16:52       ` Daniel Colascione

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=5352D06E.7000403@siege-engine.com \
    --to=eric@siege-engine.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    /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).