VLCs: Managing Parallelism with Virtualized Libraries

Yineng Yan, William Ruys, Hochan Lee, Ian Henriksen, Arthur Peters, King S. Stephens, Bozhi You, Henrique Fingler, Martin Burtscher, Milos Gligoric, Keshav Pingali, Mattan Erez, George Biros, Christopher J. Rossbach

Abstract As the complexity and scale of modern parallel machines continue to grow, programmers increasingly rely on composition of software libraries to encapsulate and exploit parallelism. However, many libraries are not designed with composition in mind and assume they have exclusive access to all resources. Using such libraries concurrently can result in contention and degraded performance. Prior solutions involve modifying the libraries or the OS, which is often infeasible. We propose Virtual Library Contexts (VLCs), which are process subunits that encapsulate sets of libraries and associated resource allocations. VLCs control the resource utilization of these libraries without modifying library code. This enables the user to partition resources between libraries to prevent contention, or load multiple copies of the same library to allow parallel execution of otherwise thread-unsafe code within the same process. In this paper, we describe and evaluate C++ and Python prototypes of VLCs. Experiments show VLCs enable a speedup up to 2.85x on benchmarks including applications using OpenMP, OpenBLAS, and LibTorch.

Introduction

Modern scientific computing and machine learning applications frequently compose multiple highly optimized, multi-threaded libraries such as OpenMP, OpenBLAS, and PyTorch. A significant challenge arises because these libraries are typically "greedy"—designed with the assumption that they have exclusive access to all available hardware resources. When an application attempts to run multiple such libraries concurrently, they often compete for the same CPU cores or GPUs, leading to severe resource contention and performance degradation, a phenomenon known as oversubscription.

Historically, addressing this issue required either a complete rewrite of libraries to use a unified task scheduler or modifications to the operating system kernel to enforce resource isolation. Neither approach is practical for large-scale legacy systems or closed-source software. This paper introduces Virtual Library Contexts (VLCs), a lightweight, user-space mechanism that provides library-level virtualization to manage parallelism effectively without requiring modifications to the libraries or the underlying OS.

Virtual Library Contexts (VLCs)

VLCs function as process subunits that encapsulate specific libraries and their associated resource allocations. By providing a layer of virtualization entirely in user space, VLCs allow developers to partition hardware resources among different libraries within a single process.

Comparison of VMs, Containers, and VLCs architecture.

The VLC architecture achieves isolation and resource control through several key mechanisms:

  • Library Isolation: VLCs utilize Linux linker namespaces (via dlmopen in C++) to load isolated copies of shared libraries. This ensures each instance maintains its own static state. In Python, this is achieved by overriding the builtins.__import__ mechanism to route module loading into specific contexts.
  • Resource Virtualization: To prevent oversubscription, VLCs intercept system calls (e.g., sched_getaffinity) and file reads (e.g., /proc/cpuinfo) using ptrace and seccomp BPF. The VLC Monitor provides forged responses, tricking the library into perceiving only the subset of resources assigned to its specific VLC.
  • Service VLCs: For libraries that are incompatible with dlmopen (such as CUDA or certain pthreads implementations), VLCs use "Service VLCs." These problematic libraries are loaded globally, and compile-time shims route calls from isolated VLCs to the global instance.
  • Auto-tuning: Since optimal resource partitioning is often non-obvious, the system includes a grid-search auto-tuner to automatically identify the most efficient distribution of cores.

Key Insights

A primary insight of this work is that "illusion is cheaper than rewriting." By intercepting resource queries and providing tailored hardware views, VLCs resolve contention without the need for invasive code changes. Furthermore, VLCs enable thread-safety through duplication; legacy libraries that rely on global static state can be safely run in parallel by loading multiple instances into separate linker namespaces. This also unlocks nested parallelism, allowing asymmetric core partitioning to maximize hardware utilization.

Evaluation and Results

The VLC system was evaluated using a variety of high-performance computing (HPC) and machine learning workloads, including the Rodinia 3.1 test suite, OpenBLAS kernels, and PyTorch models.

Speedup ratio of VLCs compared to default and best-configuration baselines as the number of simultaneous tasks increases.

The results demonstrate significant performance improvements:

  • Hyperparameter Tuning: In a C++ LibTorch environment tuning a Transformer model, VLCs achieved a 6.43x speedup over sequential execution and a 2.61x speedup over the default concurrent setup.
  • Synthetic Workflows: Mixed workloads involving multiphysics and N-body simulations saw up to a 2.85x speedup (averaging 2.05x) by eliminating contention.
  • Nested Parallelism: Mixed-size matrix multiplications (GEMMs) achieved a 1.58x speedup over sequential execution.
  • Thread-Unsafe Parallelization: Concurrent ARPACK eigenvalue solvers, which are traditionally thread-unsafe, achieved a 1.96x speedup when isolated via VLCs.

Crucially, the runtime overhead of VLCs is negligible, measured at under 1% for end-to-end applications. System call interception takes only microseconds and typically occurs only during library initialization.

Conclusion and Future Work

VLCs provide a practical and efficient solution for managing library-level parallelism in modern complex applications. While currently limited by the dynamic linker's namespace constraints (typically 16 in glibc), future work aims to expand virtualization to memory capacity and network interfaces. Additionally, the authors plan to replace the exhaustive grid-search auto-tuner with machine learning models to more rapidly identify optimal resource configurations.

Summary updated

BibTeX
@misc{yan2025vlcs,
  author = {Yineng Yan and William Ruys and Hochan Lee and Ian Henriksen and Arthur Peters and King S. Stephens and Bozhi You and Henrique Fingler and Martin Burtscher and Milos Gligoric and Keshav Pingali and Mattan Erez and George Biros and Christopher J. Rossbach},
  title = {{VLCs: Managing Parallelism with Virtualized Libraries}},
  year = {2025},
  eprint = {2512.04320},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.04320},
  howpublished = {arXiv},
}
Figure