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 types 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.
Introduction
As software systems evolve, they inevitably suffer from architectural drift and erosion—the widening gap between the original design and the actual implementation. For architects and developers, understanding the "as-built" architecture is critical for long-term maintenance and system health. However, manually mapping implementation-level entities to high-level architectural components is a Herculean task, often requiring hundreds of hours for large-scale codebases.
While automated architecture recovery tools have been developed to cluster code entities into modules, existing solutions generally suffer from two primary flaws. First is information scarcity: most tools rely on a single signal (typically structural dependencies), ignoring the rich context provided by directory structures or developer comments. Second is coarse granularity: many tools treat all code relationships as equal, failing to distinguish between a critical function call and a minor variable reference. To bridge this gap, we introduce SARIF (Software Architecture Recovery with Information Fusion).
The SARIF Methodology
SARIF is a fully automated technique that operates through four distinct stages to provide a more nuanced view of software systems.
1. Information Extraction
SARIF extracts three categories of information to ensure a comprehensive view of the system:
- Fine-grained Dependencies: Rather than treating all links as generic edges, SARIF identifies 13 different types of dependencies.
- Source Code Text: This includes comments, class names, and function names, which capture the semantic intent of the developers.
- Directory Structure: The physical organization of files often reflects the intended logical architecture.
2. Information Refinement
To move beyond coarse-grained analysis, SARIF applies several refinement techniques:
- Inversed PageRank (IPR): Standard PageRank often flags utility functions (e.g.,
string_equal) as "important" because they are called frequently. SARIF’s IPR correctly identifies that the callers of these functions—the module interfaces—are the true architectural anchors. - Dependency Weighting: SARIF employs an optimization algorithm to automatically assign weights to different dependency types. For instance, an
ImplLink(implementation link) is weighted significantly higher than a simpleUserelationship. - Topic Modeling: Using Latent Dirichlet Allocation (LDA), SARIF transforms raw code text into topic embeddings, allowing the system to group entities based on functional similarity.
3. Adaptive Information Fusion
Not all signals are equally useful for every project. For example, a messy folder structure can mislead recovery efforts. SARIF calculates dynamic weights for textual and folder information by measuring how well they align with the structural dependency graph. If a specific signal is found to be low-quality or inconsistent, SARIF automatically down-weights it to prevent it from polluting the final results.
4. Clustering
Finally, SARIF fuses these refined signals into a single weighted graph. It then applies a fast community detection algorithm to partition the system into distinct architectural modules.
Experimental Evaluation
We evaluated SARIF using a robust two-part dataset:
- Benchmark Projects: Nine software systems with human-labeled ground-truth architectures. This includes six established benchmarks (e.g., Hadoop, Chromium, Bash) and three new projects labeled by industrial collaborators (Libxml2, Distributed Camera, and Drivers Framework).
- Generalizability Set: A collection of 900 GitHub projects across C, C++, and Java to verify the tool’s performance across different languages and scales.
To ensure an honest assessment, we introduced two new metrics—Adjusted Rand Index (ARI) and an adjusted a2a ($a2a_{adj}$)—to address biases in traditional metrics like MoJoFM, which can have limited dynamic range.
Key Results
SARIF demonstrated significant improvements over nine state-of-the-art (SOTA) techniques:
- Accuracy: SARIF achieved a 36.1% average improvement in accuracy across all metrics. In 40 experimental runs, SARIF secured the top score in 77.8% of cases.
- Scalability: The tool is highly efficient, processing the Chromium codebase (over 10 million lines of code) in approximately 80 minutes.
- Ablation Studies: Removing any single component (text, folders, or dependency weighting) led to a significant drop in accuracy, validating the necessity of the multi-source fusion approach.
Discussion and Limitations
While SARIF represents a significant step forward, some challenges remain. In certain projects, such as OODT, SARIF’s default settings produced fewer clusters than the ground truth. While adjusting a "resolution" parameter can resolve this, the tool currently lacks an automated mechanism to predict the exact number of clusters a human architect might expect. Additionally, as a static analysis tool, SARIF may face difficulties with highly dynamic language features or complex pointer indirections that obscure dependencies.
Conclusion
SARIF demonstrates that the key to accurate software architecture recovery lies in the intelligent fusion of diverse information sources. By refining dependencies through Inversed PageRank and adaptively weighting textual and structural signals, SARIF provides a highly accurate, scalable solution for maintaining architectural documentation in evolving software systems.
Summary updated