Page MenuHomeFreeBSD

Make rtld use read(2) instead of mmap(2) for ELF headers
Needs ReviewPublic

Authored by trasz on Nov 18 2017, 10:00 AM.



Make rtld use read(2) instead of mmap(2) for ELF headers. This results
in one fewer syscall per shared object. It's similar to Linux behaviour.
On amd64 it results in a rather trivial performance gain - ~0.1% faster
time for a binary that's linked against five libraries and doesn't do
much otherwise.

Diff Detail

rS FreeBSD src repository - subversion
Lint OK
No Unit Test Coverage
Build Status
Buildable 12826
Build 13090: arc lint + arc unit

Event Timeline

Using read means that the you use twice as much memory, and due to the malloc() internals, the allocated memory is not returned to the system. Mmaped page is remapped when the text is mapped, and de-facto prefaulted.

Why twice?

As for returning the memory - yup, it's additional 4kB of swap per process. Still, I believe the relative overhead of the calls to munmap(2) removed is larger.