GSmart: An Efficient SPARQL Query Engine Using Sparse Matrix Algebra - Full Version

Yuedan Chen, M. Tamer Özsu, Guoqing Xiao, Zhuo Tang, Kenli LiarXiv 2021

Abstract

The Resource Description Framework (RDF) is the foundational data model for the Semantic Web and large-scale knowledge graphs. However, querying this data using SPARQL is computationally intensive, often hampered by slow relational joins or irregular memory access patterns in graph-based engines. This paper introduces gSmart, a high-performance SPARQL query engine that reimagines RDF data as sparse matrices. By leveraging "grouped incident edge-based evaluation" and optimizing for heterogeneous CPU-GPU architectures, gSmart achieves up to a 46,920x speedup over traditional engines and demonstrates strong scalability across high-performance computing (HPC) nodes.

Introduction

Existing SPARQL engines typically follow two paradigms: relational-based (treating queries as table joins) or graph-based (treating queries as subgraph matching). Both approaches have significant drawbacks: relational joins scale poorly with query complexity, and graph-based methods suffer from "pointer-chasing"—irregular memory access that performs poorly on modern parallel hardware like GPUs. While matrix-based approaches have been proposed, they often struggle with massive communication overhead between the CPU and GPU. gSmart bridges this gap by transforming graph traversals into linear algebra operations optimized for heterogeneous architectures.

Methodology

gSmart treats the RDF dataset as a massive sparse matrix where subjects and objects are indices, and predicates are the values. This allows the engine to replace traditional traversals with highly parallelizable matrix operations.

Sparse Matrix Representation

As illustrated in Figure 4, the RDF graph structure is mapped directly to a sparse matrix. This transformation enables the use of matrix-vector and matrix-matrix multiplications to evaluate query constraints.

Mapping RDF graph structures to sparse matrix representations

Grouped Incident Edge Evaluation

Instead of evaluating one triple pattern at a time, gSmart evaluates all unevaluated edges connected to a vertex simultaneously. This approach uses matrix algebra to apply multiple constraints at once, drastically pruning the search space early in the execution process.

Optimized Storage and Planning

  • LSpM (Light-weight Sparse Matrix) Storage: A custom format based on CSR and CSC that stores only the predicates required for a specific query, minimizing memory footprint.
  • Graph-Based Query Planner: Uses direction-driven and degree-driven strategies to determine the optimal evaluation order, aiming to minimize intermediate result sizes.
  • Tree-Based Binding Storage: Stores intermediate results in a tree structure, which is more memory-efficient than flat tables and simplifies final join operations.

Hardware-Aware Optimization

A primary challenge in GPU acceleration is the communication bottleneck across the PCIe bus. gSmart is designed to align with the hardware hierarchy of modern HPC clusters, as shown in Figure 6.

Heterogeneous CPU-GPU architecture and the PCIe communication bottleneck

By performing bitwise AND/OR operations within the matrix multiplication on the GPU, gSmart can "pre-prune" invalid results before they leave the high-speed device memory. This minimizes the data that must be transferred back to the host memory, effectively mitigating the PCIe bottleneck.

Experimental Evaluation

The authors evaluated gSmart using three major benchmarks: WatDiv-100M (synthetic), YAGO2 (real-world), and LUBM-1B (large-scale synthetic).

Key Results

  • Massive Speedups: On a single node, gSmart outperformed the relational-based RDF-3X by up to 46,920x on the YAGO2 dataset.
  • Superiority over Matrix Rivals: Compared to MAGiQ (a leading matrix-based competitor), gSmart was significantly faster due to its superior pruning and specialized LSpM storage.
  • Scalability: Tested on the Tianhe-1A supercomputer, gSmart achieved a 6.90x speedup when scaling from 2 to 16 nodes for data-intensive queries.
  • Workload Efficiency: For complex queries, the overhead of moving data to the GPU was consistently outweighed by the massive parallel processing gains.

Conclusion and Future Work

gSmart demonstrates that reimagining RDF querying as sparse matrix algebra allows for unprecedented performance on modern hardware. While scalability can be less pronounced for highly selective queries that return few results, the engine provides a robust solution for heavy knowledge graph workloads. Future work will focus on optimizing matrix algebra primitives for next-generation heterogeneous architectures to further push performance boundaries.

Summary updated

BibTeX
@misc{chen2021gsmart,
  author = {Yuedan Chen and M. Tamer Özsu and Guoqing Xiao and Zhuo Tang and Kenli Li},
  title = {{GSmart: An Efficient SPARQL Query Engine Using Sparse Matrix Algebra - Full Version}},
  year = {2021},
  eprint = {2106.14038},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2106.14038},
}
Figure