struct filedesc0 eats > 1024 bytes

Mateusz Guzik mjguzik at gmail.com
Thu Oct 30 01:22:20 UTC 2014


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>


More information about the freebsd-hackers mailing list