Software Architecture Recovery with Information Fusion

Yiran Zhang, Zhengzi Xu, Chengwei Liu, Hongxu Chen, Jianwen Sun, Dong Qiu, Yang Liu

TL;DR

SARIF is a new automated tool that recovers software architecture by fusing three distinct signals: fine-grained code dependencies, textual information (via topic modeling), and folder structures. By using an adaptive weighting scheme and refined graph algorithms, it achieves a 36.1% improvement in accuracy over state-of-the-art techniques.

What Problem Does This Paper Address?

As software systems evolve, they inevitably suffer from architectural drift and erosion—the gap between the original design and the actual implementation. For architects, understanding the "as-built" architecture is critical for maintenance, but doing so manually is a Herculean task that can take hundreds of hours for large codebases.

Existing automated recovery tools (which cluster code entities into high-level components) generally suffer from two flaws:

  1. Information Scarcity: Most tools rely on only one or two signals (usually just structural dependencies), ignoring the rich context provided by directory structures or developer comments.
  2. Coarse Granularity: They often treat all code relationships as equal. In reality, a "Function Call" provides much more architectural insight than a simple "Variable Use," yet many tools don't distinguish between them.

Methods

The authors propose SARIF (Software Architecture Recovery with Information Fusion), which operates in four main stages:

  • Information Extraction: It extracts fine-grained dependencies (13 different types), source code text (comments, class/function names), and the directory tree.
  • Information Refinement: This is where the "intelligence" happens.
  • SARIF uses Inversed PageRank (IPR) to identify influential nodes (like module interfaces) rather than just "popular" utility functions.
  • It employs an optimization algorithm to automatically assign weights to different dependency types (e.g., ImplLink is weighted much higher than Use).
  • It uses Latent Dirichlet Allocation (LDA) to transform raw code text into topic embeddings.
  • Information Fusion: Not all signals are useful for every project. SARIF calculates a dynamic weight for textual and folder information by comparing how well they align with the structural dependency graph. If a folder structure is messy, SARIF automatically down-weights it.
  • Clustering: Finally, it fuses these signals into a single weighted graph and applies a fast community detection algorithm to partition the system into architectural modules.

Datasets

The study uses a robust two-part evaluation:

  1. Benchmark Projects: 9 software systems with human-labeled ground-truth architectures. This includes 6 established benchmarks (like Hadoop, Chromium, and Bash) and 3 new projects labeled by industrial collaborators (Libxml2, Distributed Camera, and Drivers Framework).
  2. Generalizability Set: A massive collection of 900 GitHub projects across C, C++, and Java to verify that the tool works across different languages and scales.

Key Insights and Ideas

  • The Utility Function Trap: Standard PageRank often flags utility functions (like string_equal) as "important" because they are called everywhere. SARIF’s use of Inversed PageRank correctly identifies that the callers of many functions (the interfaces) are the true architectural anchors.
  • Context Matters: Folder structures are often great indicators of architecture, but sometimes they are misleading (e.g., putting all header files in one include folder). SARIF’s ability to adaptively filter these "useless" folders prevents them from polluting the recovery result.
  • Metric Reform: The authors argue that common metrics like MoJoFM and $a2a$ are biased or have limited dynamic range. They introduce Adjusted Rand Index (ARI) and a new adjusted $a2a$ ($a2a_{adj}$) to provide a more "honest" assessment of how similar two architectures really are.

Key Results

  • Superior Accuracy: SARIF outperformed nine state-of-the-art techniques, showing a 36.1% average improvement in accuracy across all metrics.
  • Top Performance: Out of 40 experimental runs (8 projects × 5 metrics), SARIF achieved the #1 score in 77.8% of cases and a Top-2 score in 88.9% of cases.
  • Scalability: The tool is highly efficient. It processed the Chromium codebase (over 10 million lines of code) in approximately 80 minutes, with the vast majority of that time spent on initial information extraction.
  • Ablation Success: Removing any single component (text, folders, or dependency weighting) led to a significant drop in accuracy, proving that "information fusion" is indeed the key to its success.

Limitations and Future Work

  • Granularity Mismatch: In one project (OODT), SARIF’s default settings produced far fewer clusters than the ground truth. While the authors showed that adjusting a "resolution" parameter fixes this, the tool currently lacks an automated way to guess the "correct" number of clusters a human might expect.
  • Static Analysis Bounds: Like all tools relying on static analysis, SARIF may struggle with highly dynamic language features or complex pointer indirection that obscures dependencies.
  • Future Directions: The authors suggest incorporating more explicit domain knowledge and commonly-adopted architectural patterns (like Model-View-Controller) to further refine the clustering logic.

Summary updated

Abstract

Understanding the architecture is vital for effectively maintaining and managing large software systems. However, as software systems evolve over time, their architectures inevitably change. To keep up with the change, architects need to track the implementation-level changes and update the architectural documentation accordingly, which is time-consuming and error-prone. Therefore, many automatic architecture recovery techniques have been proposed to ease this process. Despite efforts have been made to improve the accuracy of architecture recovery, existing solutions still suffer from two limitations. First, most of them only use one or two type of information for the recovery, ignoring the potential usefulness of other sources. Second, they tend to use the information in a coarse-grained manner, overlooking important details within it. To address these limitations, we propose SARIF, a fully automated architecture recovery technique, which incorporates three types of comprehensive information, including dependencies, code text and folder structure. SARIF can recover architecture more accurately by thoroughly analyzing the details of each type of information and adaptively fusing them based on their relevance and quality. To evaluate SARIF, we collected six projects with published ground-truth architectures and three open-source projects labeled by our industrial collaborators. We compared SARIF with nine state-of-the-art techniques using three commonly-used architecture similarity metrics and two new metrics. The experimental results show that SARIF is 36.1% more accurate than the best of the previous techniques on average. By providing comprehensive architecture, SARIF can help users understand systems effectively and reduce the manual effort of obtaining ground-truth architectures.
BibTeX
@inproceedings{zhang2023software,
  author = {Yiran Zhang and Zhengzi Xu and Chengwei Liu and Hongxu Chen and Jianwen Sun and Dong Qiu and Yang Liu},
  title = {{Software Architecture Recovery with Information Fusion}},
  booktitle = {ESEC/SIGSOFT FSE},
  year = {2023},
  doi = {10.1145/3611643.3616285},
}

Loading related content...

Figure