Skip to content

pv-runtime: Avoid opening libraries to determine their SONAME

Simon McVittie requested to merge wip/smcv/speed-up-deletion into master
  • glnx-dirfd: Add a rewinddir() wrapper

    This is useful in the same situations rewinddir() is. My use-case right now is to remove some of the files from a directory, then go back through the directory removing symlinks that pointed to those files.

    Forwarded: https://gitlab.gnome.org/GNOME/libglnx/-/merge_requests/25

  • pv-runtime: Don't early-return in pv_runtime_remove_overridden_libraries()

    We need to 'goto out' to free some arrays of objects, which are too complicated for __attribute__((__cleanup__)).

  • pv-runtime: When deleting overridden libraries, give clearer examples

    The comments here are not really clear enough to express what's going on, particularly in the presence of libraries that have aliases.

  • pv-runtime: Delete libraries that are overridden by an alias

    If we got libbz2.so.1.0 from the host, for which libbz2.so.1 is an alias, we will also want to remove libbz2.so.1 from the container.

  • pv-runtime: Remove targets of overridden SONAME symlinks

    If libfoo.so.0 is a symlink pointing to libfoo.so.0.1.2, and we have overridden libfoo.so.0, then we can know that libfoo.so.0.1.2 is also to be avoided, even without opening it to determine its SONAME. This reduces the need to use libelf, which is surprisingly slow if the disk cache is cold.

  • pv-runtime: Delete dangling development symlinks to overridden libraries

    Some development libraries follow this pattern, and we already delete those without needing to use libelf to load the library and find out its SONAME:

      libfcitx-config.so -> libfcitx-config.so.4
      libfcitx-config.so.4 -> libfcitx-config.so.4.1
      libfcitx-config.so.4.1

    However, other libraries follow this pattern, which results in the code that uses libelf to find the SONAME being the only way we can figure out that the .so symlink needs removing:

      libdbus-glib-1.so -> libdbus-glib-1.so.2.2.2
      libdbus-glib-1.so.2 -> libdbus-glib-1.so.2.2.2
      libdbus-glib-1.so.2.2.2

    To avoid relying on the libelf code path, which is surprisingly slow when run with a cold disk cache, we can do one scan through the directory removing regular files and runtime symlinks, and a second scan through the directory removing development symlinks that have become dangling as a result.

  • pv-runtime: Avoid opening libraries to determine their SONAME

    This is surprisingly expensive to do, particularly with a cold cache. If we can avoid this, then deleting unwanted libraries from the mutable copy of the runtime becomes a lot faster.

    With the disk cache cleared and running on slow hardware, this cuts down deletion of the unwanted libraries from 2-4 seconds to basically instantaneous.

  • pressure-vessel: Remove utility function to look up ELF SONAME

    This is no longer used.

Edited by Simon McVittie

Merge request reports