SVNews r326640

NOTE: This service is experimental and subject to change! Use at your own risk!

2017-12-06 22:06:48 - r326640 by asomers (asomers)

Complete list of files affected by revision r326640:

(Note: At the moment, these links point to ViewVC on They are probably slow. Do not overuse.)

  History   Contents   Diff   MODIFY   /head/lib/libc/gen/telldir.c  
  History   Contents   Diff   MODIFY   /head/lib/libc/gen/telldir.h  
  History   Contents   Diff   MODIFY   /head/lib/libc/tests/gen/Makefile  
  History   Contents     ADD   /head/lib/libc/tests/gen/dir2_test.c  

Commit message:

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

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:


Powered by Python FreeBSD support by secnetix GmbH & Co. KG

Page generated in 8 ms, 4 files printed. Current time is 2018-03-21 11:00:18. All times are in UTC/GMT.