Re: inotify to minimize stat() calls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 13, 2013 at 3:48 AM, Karsten Blees <karsten.blees@xxxxxxxxx> wrote:
> 2.) 0.135 s is spent in name-hash.c/hash_index_entry_directories, reindexing the same directories over and over again. In the end, the hashtable contains 939k directory entries, even though the WebKit test repo only has 7k directories. Checking if a directory entry already exists could reduce that, i.e.:

This function is only used when core.ignorecase = true. I probably
won't be able to test this, so I'll leave this to other people who
care about ignorecase.

This function used to have lookup_hash, but it was removed by Jeff in
2548183 (fix phantom untracked files when core.ignorecase is set -
2011-10-06). There's a looong commit message which I'm too lazy to
read. Anybody who works on this should though.


> @@ -53,14 +55,23 @@ static void hash_index_entry_directories(struct index_state *istate, struct cach
>         unsigned int hash;
>         void **pos;
>         double t = ticks();
> +       struct cache_entry *ce2;
> +       int len = ce_namelen(ce);
>
> -       const char *ptr = ce->name;
> -       while (*ptr) {
> -               while (*ptr && *ptr != '/')
> -                       ++ptr;
> -               if (*ptr == '/') {
> -                       ++ptr;
> -                       hash = hash_name(ce->name, ptr - ce->name);
> +       while (len > 0) {
> +               while (len > 0 && ce->name[len - 1] != '/')
> +                       len--;
> +               if (len > 0) {
> +                       hash = hash_name(ce->name, len);
> +                       ce2 = lookup_hash(hash, &istate->name_hash);
> +                       while (ce2) {
> +                               if (same_name(ce2, ce->name, len, ignore_case)) {
> +                                       add_since(t, &hash_dirs);
> +                                       return;
> +                               }
> +                               ce2 = ce2->dir_next;
> +                       }
> +                       len--;
>                         pos = insert_hash(hash, ce, &istate->name_hash);
>                         if (pos) {
>                                 ce->dir_next = *pos;
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]