On Sat, Dec 19, 2009 at 7:55 PM, Robert Dodier <robert.dodier@gmail.com> wrote:
On 12/18/09, Juan Jose Garcia-Ripoll
> No, you are not seeing the same behavior as before. Before, if ECL wanted to
> list a directory of /var/tmp/foo/a.txt it would run through the directory
> chain "stat-ing" the content of /var, /tmp and /foo Now it only does what is
> expected: it lists the content of each directory, and only inspect those
> that match the masks "var", "tmp", "foo" and "a.txt" There are thus only a
> few calls to "stat" which HAVE to be done: "var", "tmp", "foo" have to be
> verified not to be files, and for "a.txt" we have to verify it is not a
> symbolic link or return its true name.

OK, I tried it again, and I see a reduction in stat calls now;
before the executable was linking to the previous libecl.so,
so I didn't see any change.

Some of the unneeded calls to stat have gone away, which
is good. However there are still some unnecessary calls to stat,
e.g. (directory (pathname "/var/tmp/foo")) stats everything
in in /var/tmp and (directory (pathname "/var/tmp/foo/quux.1"))
stats everything in /var/tmp/foo.

Fixed in CVS. I used this chance to further unify the implementations of DIRECTORY and PATHNAME-MATCH-P. Will be conducting some automated tests tonight to ensure nothing else broke

A simple test follows. Given a directory with two files

$ ls -l mtp
total 0
-rw-r--r-- 1 jjgarcia jjgarcia 0 2009-12-20 00:16 foo
-rw-r--r-- 1 jjgarcia jjgarcia 0 2009-12-20 00:16 foo2

Before ECL would stat both

$ (strace ./tmp/intel64.all/bin/ecl -norc -eval '(directory "~/mtp/foo2")' -eval '(quit)') 2>&1 |grep stat
[...]
stat("home", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("jjgarcia", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("mtp", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("foo", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
stat("foo2", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0

With the latest fix it only stats the file that matches the mask

$ (strace ./tmp/intel64/bin/ecl -norc -eval '(directory "~/mtp/foo2")' -eval '(quit)') 2>&1 |grep stat
[...]
stat("home", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("jjgarcia", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("mtp", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("foo2", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0

Juanjo

--
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com