Re: [PATCH/RFC v3 1/2] Optimised, faster, more effective symlink/directory detection
From: Pete Harlan <hidden>
Date: 2016-06-15 22:45:53
Here are some suggestions for the commit message. Kjetil Barvik wrote:
Changes includes the following: - The cache functionality is more effective. Previously when A/B/C/D was in the cache and A/B/C/E/file.c was called for, there was no match at all from the cache. Now we use the fact that the paths "A", "A/B" and "A/B/C" is already tested, and we only need to do an
is -> are
lstat() call on "A/B/C/E". - We only cache/store the last path regardless of it's type. Since the
it's -> its
cache functionality is always used with alphabetically sorted names (at least it seams so for me), there is no need to store both the
seams -> seems
last symlink-leading path and the last real-directory path. Note that if the cache is not called with (mostly) alphabetically sorted names, neither the old, nor this new one, would be very effective. - We also can cache the fact that a directory does not exist. Previously we could end up doing lots of lstat() calls for a removed directory which previously contained lots of files. Since we already have simplified the cache functionality and only store the last path (see above), this new functionality was easy to add. - Previously, when symlink A/B/C/S was cached/stored in the symlink-leading path, and A/B/C/file.c was called for, it was not easy to use the fact that we already known that the paths "A", "A/B"
known -> knew
and "A/B/C" is real directories. Since we now only store one single
is -> are
path (the last one), we also get similar logic for free regarding the new "non-exsisting-directory-cache". - Avoid copying the first path components of the name 2 zillions times
zillions -> zillion
when we tests new path components. Since we always cache/store the
tests -> test
last path, we can copy each component as we test those directly into the cache. Previously we ended up doing a memcpy() for the full path/name right before each lstat() call, and when updating the cache for each time we have tested an new path component.
an -> a
- We also use less memory, that is PATH_MAX bytes less memory on the
is -> is,
stack and PATH_MAX bytes less memory on the heap.
Cheers, --Pete