Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Jan 2018 21:54:34 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-standards@FreeBSD.org
Subject:   [Bug 218622] libc/gen/telldir [hack-n-PATCH] performance limited to O(n) vs file count, O(n^2) against samba ls workload
Message-ID:  <bug-218622-15-OFpjyIbJWj@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-218622-15@https.bugs.freebsd.org/bugzilla/>
References:  <bug-218622-15@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D218622

Alan Somers <asomers@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |asomers@FreeBSD.org

--- Comment #7 from Alan Somers <asomers@FreeBSD.org> ---
FWIW I have further improved upon mav's solution with r326640.  Now, telldi=
r is
O(1) in both time and space on 64-bit systems.

r326640 | asomers | 2017-12-06 15:06:48 -0700 (Wed, 06 Dec 2017) | 22 lines

Optimize telldir(3)

Currently each call to telldir() requires a malloc and adds an entry to a
linked list which must be traversed on future telldir(), seekdir(),
closedir(), and readdir() calls. Applications that call telldir() for every
directory entry incur O(n^2) behavior in readdir() and O(n) in telldir() and
closedir().

This optimization eliminates the malloc() and linked list in most cases by
packing the relevant information into a single long. On 64-bit architectures
msdosfs, NFS, tmpfs, UFS, and ZFS can all use the packed representation.  On
32-bit architectures msdosfs, NFS, and UFS can use the packed
representation, but ZFS and tmpfs can only use it for about the first 128
files per directory.  Memory savings is about 50 bytes per telldir(3) call.
Speedup for telldir()-heavy directory traversals is about 20-30x for one
million files per directory.

Reviewed by:    kib, mav, mckusick
MFC after:      3 weeks
Sponsored by:   Spectra Logic Corp
Differential Revision:  https://reviews.freebsd.org/D13385

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-218622-15-OFpjyIbJWj>