Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 04 Dec 2003 16:24:10 +0100
From:      des@des.no (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=)
To:        Tim Robbins <tjr@freebsd.org>
Cc:        current@FreeBSD.ORG
Subject:   Re: Port of Niels Provos's file descriptor allocation code
Message-ID:  <xzpllpsfvxh.fsf@dwp.des.no>
In-Reply-To: <20031204083256.GA39396@wombat.robbins.dropbear.id.au> (Tim Robbins's message of "Thu, 4 Dec 2003 19:32:56 %2B1100")
References:  <20031127070239.GA12950@wombat.robbins.dropbear.id.au> <20031204075445.GA96485@VARK.homeunix.com> <20031204083256.GA39396@wombat.robbins.dropbear.id.au>

next in thread | previous in thread | raw e-mail | index | archive | help
Tim Robbins <tjr@freebsd.org> writes:
> It doesn't seem to make a noticeable impact on execution time for process=
es
> with small numbers of descriptors. It's probably swamped by the overhead =
of
> mode switches, locking, and filesystem operations. What makes uneasy is t=
he
> amount of extra memory it consumes when processes have a small number of
> descriptors: (32**2)/8 =3D 128 bytes (when int is 32 bits), or (64**2)/8 =
=3D
> 512 bytes (when int is 64 bits).

I'm not sure where you get these numbers from.  Actual growth of
struct filedesc is:

 - two pointers
 - one 32-bit int (himap) (used when nfiles <=3D 1024)
 - one array of 32 32-bit ints (lomap) (used when nfiles <=3D 1024)

For higher values of nfiles, larger arrays are malloc'ed and the
static arrays are left unused.

The total is 35*4 =3D 140 bytes per struct filedesc on 32-bit platforms
and 2*8 + 33*4 =3D 148 bytes per struct filedesc on 64-bit platforms.

Modifying the code to use 64-bit ints on 64-bit platforms would change
that number to 67*8 =3D 536 bytes per struct filedesc, but the cutoff
would be at nfiles =3D=3D 4096 instead of 1024.

>                                  I've been thinking of switching to a flat
> bitmap for small fd tables, possibly just using a single "int", or falling
> back to the old way of scanning fd_ofiles directly.

That would increase code complexity.  The patch already increases fd
allocation overhead by about 7% on my ev56 and 1% on my p4 for low
values of nfiles (though the performance improvement for higher values
is immense).  It is possible that a pure 64-bit implementation would
fare better on the Alpha than the current 32-bit implementation.

>                                                     Once I decide what to
> do about that and find someone to test my latest patch on a 64-bit machin=
e,
> I'll commit it.

It works fine on my Alpha, using 32-bit ints.  I haven't tried
modifying the patch to use 64-bit ints on 64-bit platforms.

DES
--=20
Dag-Erling Sm=F8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzpllpsfvxh.fsf>