git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH/RFC v3 1/2] Optimised, faster, more effective symlink/directory detection

From
PHPete Harlan <pgit@pcharlan.com>
Date
Jan 9, 2009, 10:20 UTC
Message-ID
<496724E2.6010907@pcharlan.com>
In-Reply-To
<1231334689-17135-2-git-send-email-barvik@broadpark.no>
Here are some suggestions for the commit message.
Kjetil Barvik wrote:
Show 6 quoted lines
> 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
Show 13 quoted lines
>   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
Previous: Kjetil BarvikNext: Kjetil Barvik
Message 3 of 4 in “git checkout: optimise away lots of lstat() calls”
  1. 0/2 git checkout: optimise away lots of lstat() callsKjetil Barvik, Jan 7, 2009
  2. 1/2 Optimised, faster, more effective symlink/directory detectionKjetil Barvik, Jan 7, 2009
  3. Pete HarlanJan 9, 2009
  4. 2/2 create_directories() inside entry.c: only check each directory once!Kjetil Barvik, Jan 7, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.