Expanding the musl-libc Dynamic Loader by Morsel Support

Context

When a program is compiled into a dynamically linked ELF file, not all libraries the program uses are included in it. Instead, they only contain references to them. When the program is started, a dynamic loader is invoked. Its job is to map the dynamic libraries needed into the process' address space.

When multiple processes open a dynamic library, Linux shares the pages containing the library between the processes. The page tables, however, have to be newly generated for every process.

Problem

Morsels are self-contained virtual-memory objects. Essentially, they are subtrees of the page table tree and share their page table tree across processes. This means that the page tables in the morsels only have to be generated once, which should reduce the time needed to map a shared library into the address space. In order to further investigate this, the dynamic loader has to have support for morsels.

Goal

In your thesis, you implement support for morsels into the musl-libc dynamic loader. With this implementation, you can then analyze the startup behavior of applications with and without morsels.

Your thesis could follow these key steps:

  1. Familiarize yourself: Familiarize yourself with morsels and their implementation, as well as musl's dynamic loader.

  2. Implement morsel support: Add support for morsels to the dynamic loader. This may require adding custom linker scripts to achieve the correct alignment.

  3. Analyze and evaluate: Analyze the behavior and performance of applications during startup and runtime. For this, you could leverage microbenchmarks and flamegraphs.

  4. Optimize: Optimize your implementation based on your previous analysis. This might include tweaking the alignment, page size, morsel order, ...

  5. (Optional) iTLB: If there is time left, you can investigate the performance impact of the iTLB when mapping libraries with huge pages.

References

Dynamic linker - Wikipedia

musl libc

Papers

DIMES Workshop
Morsels: Explicit Virtual Memory Objects
Alexander Halbuer, Christian Dietrich, Florian Rommel, Daniel LohmannProceedings of the 1st Workshop on Disruptive Memory SystemsAssociation for Computing Machinery2023.
PDF Details Slides 10.1145/3609308.3625267 [BibTex]