Re: [RFC PATCH linux 2/2] fs/proc: use a hash table for the directory entries

From: Stephen Hemminger
Date: Thu Oct 02 2014 - 12:47:17 EST


On Thu, 2 Oct 2014 17:25:01 +0200
Nicolas Dichtel <nicolas.dichtel@xxxxxxxxx> wrote:

> From: Thierry Herbelot <thierry.herbelot@xxxxxxxxx>
>
> The current implementation for the directories in /proc is using a single
> linked list. This is slow when handling directories with large numbers of
> entries (eg netdevice-related entries when lots of tunnels are opened).
>
> This patch enables multiple linked lists. A hash based on the entry name is
> used to select the linked list for one given entry.
>
> The speed creation of netdevices is faster as shorter linked lists must be
> scanned when adding a new netdevice.
>
> Here are some numbers:
>
> dummy30000.batch contains 30 000 times 'link add type dummy'.
>
> Before the patch:
> time ip -b dummy30000.batch
> real 2m32.221s
> user 0m0.380s
> sys 2m30.610s
>
> After the patch:
> time ip -b dummy30000.batch
> real 1m57.190s
> user 0m0.350s
> sys 1m56.120s
>
> The single 'subdir' list head is replaced by a subdir hash table. The subdir
> hash buckets are only allocated for directories. The number of hash buckets
> is a compile-time parameter.
>
> For all functions which handle directory entries, an additional check on the
> directory nature of the dir entry ensures that pde_hash_buckets was allocated.
> This check was not needed as subdir was present for all dir entries, whether
> actual directories or simple files.
>
> Signed-off-by: Thierry Herbelot <thierry.herbelot@xxxxxxxxx>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@xxxxxxxxx>

I think the speed up is a good idea and makes sense.
It would be better to use exist hlist macros for hash table rather than
open coding it.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/