Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Oct 2014 02:22:15 +0100
From:      Mateusz Guzik <mjguzik@gmail.com>
To:        freebsd-hackers@freebsd.org
Subject:   struct filedesc0 eats > 1024 bytes
Message-ID:  <20141030012215.GB25368@dft-labs.eu>

next in thread | raw e-mail | index | archive | help
Since it is allocated from general slab and is > 1024 bytes in size, it
actually occupies 2048 bytes.

NDFILE is 20.

struct filedesc0 {
        struct filedesc fd_fd;
        SLIST_HEAD(, freetable) fd_free;
        struct  filedescent fd_dfiles[NDFILE];
        NDSLOTTYPE fd_dmap[NDSLOTS(NDFILE)];
};

(kgdb) p sizeof(struct filedesc)
$1 = 120
(kgdb) p sizeof(struct filedesc0)
$2 = 1096
(kgdb) p sizeof(struct filedescent)
$3 = 48

Unfotunately there is no way to reoder elements in included structs to
gain enough space (or at least I didn't find any).

Maybe it may be a good idea to reconsider going back to "capability fd"
which is an intermediate object in the future. Next allocation is at 32
fds and that eats over 1500 bytes.

In the meantime I propose decreasing NDFILE by 2. This gives sizeof = 1000
and leaves 24 bytes for possible future additions.

In linux they use 32 as their default, which would still keep us within this
2KB object. But it seems similarly arbitrary.

-- 
Mateusz Guzik <mjguzik gmail.com>



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