Debloating ML Systems

measuring and reducing code bloat in AI platforms

Active since 2023.

Today's machine learning systems are growing wildly in size every year. Of course, most of this code is not actually required for the intended use cases of the system - it is bloat. This code bloat can have a significant impact on the performance of ML systems, as it can increase the memory footprint, the startup time, and the energy consumption of the system - and, of course, the larger the code base, the larger the attack surface for security vulnerabilities.

In our research, we study the existence of code bloat in machine learning systems, and how it can be measured and reduced (Zhang et al., 2024). We find that most machine learning containers in most use cases exhibit 50% or more bloat.

Example growth of a real-life machine learning system

In collaboration with the Computer and Network Systems research unit at Chalmers, we built BLAFS, a bloat-aware container filesystem that removes unused files at runtime while guaranteeing the debloated container still works correctly (Zhang et al., 2026). Accessed files move into a debloating layer as the container runs, and, similar to garbage collection, files that are never accessed get removed. An optional reloading layer fetches anything mistakenly removed from a remote cache on demand.

Across the top 20 most-downloaded Docker Hub containers, four ML containers, and a 10-function serverless benchmark suite, BLAFS reduces container image sizes by up to 95% and cold starts by up to 68%. In a security-hardened mode it removes up to 89% of known CVEs, where the two state-of-the-art debloating tools we compared against, including docker-slim, largely fail on the same workloads.

Contacts:

Dr. Ahmed Ali-Eldin Hassan, CNS unit, Chalmers

Prof. Philipp Leitner


References

2026

  1. BLAFS: A Bloat-Aware Container File System
    Huaifeng Zhang, Mohannad Alhanahnah, Philipp Leitner, and Ahmed Ali-Eldin
    In Proceedings of the 2025 ACM Symposium on Cloud Computing, , Apr 2026

2024

  1. Machine Learning Systems are Bloated and Vulnerable
    Huaifeng Zhang, Mohannad Alhanahnah, Fahmi Abdulqadir Ahmed, Dyako Fatih, Philipp Leitner, and Ahmed Ali-Eldin
    Proceedings of SIGMETRICS, Feb 2024