Scaler: Efficient and Effective Cross Flow Analysis

Steven, Tang, Mingcan Xiang, Yang Wang, Bo Wu, Jianjun Chen, Tongping LiuarXiv 2024 · DOI

TL;DR

Scaler introduces Cross Flow Analysis (XFA), a novel profiling method designed to monitor and analyze the often-ignored interactions between applications and external libraries. By combining selective binary instrumentation with a high-performance Universal Shadow Table, Scaler achieves full-trace accuracy with a modest ~20% runtime overhead, exposing critical performance bugs that traditional sampling profilers miss.

What Problem Does This Paper Address?

Modern software systems are incredibly complex, relying on a web of standard and third-party libraries. Often, severe performance bottlenecks arise not from the application's core logic, but from how it interacts with these external components—such as making inappropriate API choices, misconfiguring libraries, or invoking APIs excessively.

Existing performance tools fall short of capturing these "cross-component" interactions. Sampling-based profilers (like perf) are too coarse-grained, frequently missing rapid, short-lived API calls. On the other end of the spectrum, full-trace tools (like ltrace) introduce catastrophic runtime overhead (often exceeding 6,100×), making them unusable in production or realistic development environments. Scaler bridges this gap by providing a lightweight, highly accurate full-trace profiler focused specifically on component boundaries.

Methods

Scaler achieves low-overhead full tracing through three primary technical innovations:

  1. Selective Binary Instrumentation: Instead of rewriting the entire binary or requiring source code recompilation, Scaler dynamically intercepts only the entry points where components interact. It modifies the executable's linkage tables (.rela.plt and .rela.dyn) in memory and hooks dynamic loading functions (dlsym) to redirect API calls.
  2. Universal Shadow Table (UST): To handle diverse APIs without knowing their function signatures beforehand, Scaler maps each intercepted API to a custom entry in a Universal Shadow Table. Each entry contains a compact sequence of assembly instructions that records execution context and timestamps in constant time before handing control to a common interceptor.
  3. Relation-Aware Data Folding: Logging every single API call sequentially would quickly exhaust memory. Scaler aggregates invocation counts and execution times online. Crucially, it retains "relation awareness" by grouping calls based on which specific library initiated the interaction, preserving diagnostic accuracy without a massive storage footprint.
Figure 2: Overview of Universal Shadow Table.

Datasets

The authors evaluated Scaler using:

  • The PARSEC Benchmark Suite: 13 highly optimized multithreaded applications (e.g., canneal, dedup, ferret, swaptions) representing diverse workloads.
  • Real-World Applications: Five widely deployed systems, including Memcached (1.6.17), MySQL (8.0.31), Nginx (1.23.2), Redis (7.0.4), and SQLite (3.39.4).

Key Insights and Ideas

  • Library APIs as a Window into App Design: Abnormal library API behavior can expose systemic flaws in the main application's algorithms. For example, when profiling the canneal benchmark, Scaler revealed that strcmp consumed 77% of libstdc++'s runtime. This led to the discovery that the application was inappropriately using a red-black tree (std::map) instead of a hash map (std::unordered_map) to store strings. Fixes based on this insight improved performance by 52%.
  • User-Space Tracing Beats Kernel-Space Sampling: Traditional tools like bpftrace or ltrace rely on kernel-level software breakpoints (like INT3), which trigger expensive context switches. By keeping the entire tracing and data-folding pipeline inside user space and utilizing fast thread-local storage (TLS), Scaler processes millions of events per second with minimal friction.
Figure 1: Scaler’s report for canneal.

Key Results

  • Bug Detection: Scaler successfully identified 6 performance bugs across the evaluated applications, 2 of which were previously unknown. Resolving these bugs yielded application speedups ranging from 25.5% to 76.7%. In comparison, perf was only able to detect 1 of these 6 bugs due to its coarse sampling rate.
  • Low Overhead: On average, Scaler introduces a 20.3% runtime overhead and a 15.5% memory overhead. This runtime impact is lower than sampling with perf (22.5%) or Intel VTune (41.4%), while its memory footprint is orders of magnitude smaller than perf's 6.7× memory expansion.
  • High Event Density: Scaler captured an average of 62.9 million events per second—599× more events than perf—proving that full tracing can be achieved efficiently without relying on statistical sampling.

Limitations and Future Work

  • Scope of Interception: Scaler operates strictly at the shared library boundary. It cannot detect internal application bottlenecks, hardware-specific issues (like raw cache misses from application code), or functions within statically linked libraries.
  • Future Directions: The authors plan to extend Scaler's techniques to support statically linked libraries. This will involve leveraging application symbol tables to identify internal function boundaries and rewriting their entry instructions to redirect flow to the Universal Shadow Table.

Summary updated

BibTeX
@misc{steven2024scaler,
  author = {Steven and Tang and Mingcan Xiang and Yang Wang and Bo Wu and Jianjun Chen and Tongping Liu},
  title = {{Scaler: Efficient and Effective Cross Flow Analysis}},
  year = {2024},
  eprint = {2409.00854},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2409.00854},
}

Loading related content...

Figure