[Paper Review] Generating Custom Code for Efficient Query Execution on Heterogeneous Processors
This paper proposes Hawk, a hardware-adaptive query compiler that automatically generates custom code variants for heterogeneous processors—such as CPUs, GPUs, and Intel Xeon Phi (MIC)—by exploring parallelization strategies, data structure specializations, and code transformations. It uses a learning-based strategy to select the fastest variant per processor, achieving up to two orders of magnitude performance improvement over generic code.
Processor manufacturers build increasingly specialized processors to mitigate the effects of the power wall to deliver improved performance. Currently, database engines are manually optimized for each processor: A costly and error prone process. In this paper, we propose concepts to enable the database engine to perform per-processor optimization automatically. Our core idea is to create variants of generated code and to learn a fast variant for each processor. We create variants by modifying parallelization strategies, specializing data structures, and applying different code transformations. Our experimental results show that the performance of variants may diverge up to two orders of magnitude. Therefore, we need to generate custom code for each processor to achieve peak performance. We show that our approach finds a fast custom variant for multi-core CPUs, GPUs, and MICs.
Motivation & Objective
- To address the growing challenge of processor heterogeneity in modern databases, where manual tuning is costly and error-prone.
- To eliminate the need for manual code optimization per processor by enabling automatic, hardware-aware code generation.
- To explore and evaluate multiple code variants for each processor to identify the highest-performing configuration.
- To integrate learned optimal configurations into a heuristic query optimizer for real-world deployment.
- To demonstrate that performance differences between code variants can reach up to two orders of magnitude, making custom code essential for peak performance.
Proposed method
- Introduces pipeline programs as a new physical query plan abstraction that captures operations and implementation properties for systematic code generation.
- Systematically generates code variants by modifying parallelization strategies, data structure layouts, and applying compiler transformations.
- Compiles query operators into OpenCL kernels to enable execution on any OpenCL-capable processor with low compilation overhead.
- Employs a learning strategy to profile and select the fastest code variant for each target processor based on runtime performance measurements.
- Integrates learned optimal configurations into a heuristic query optimizer to guide query execution decisions at runtime.
- Uses a produce/consume model for code generation, enabling tight loop fusion and improved data locality by processing tuples in registers.
Experimental results
Research questions
- RQ1How can database query compilers automatically generate high-performance code for diverse heterogeneous processors without manual tuning?
- RQ2What dimensions of code variation—such as parallelization strategy, data layout, and transformations—most significantly impact performance on CPUs, GPUs, and MICs?
- RQ3To what extent do performance differences between code variants vary across different processor types, and can they be systematically exploited?
- RQ4Can a learning-based approach effectively identify the optimal code variant for a given processor with minimal profiling overhead?
- RQ5How can hardware-adaptive code generation be integrated into a query optimizer to enable dynamic selection of the fastest execution path?
Key findings
- Performance differences between code variants for the same query and processor can reach up to two orders of magnitude, demonstrating the critical need for per-processor code specialization.
- The proposed approach successfully generates high-performance code for multi-core CPUs, GPUs, and Intel Xeon Phi (MIC) accelerators through automated variant exploration.
- Learning-based selection of optimal code variants achieves significant performance gains without requiring prior hardware knowledge or manual tuning.
- The pipeline program abstraction enables flexible, maintainable, and modular code generation while preserving performance-critical optimizations.
- Integration of learned configurations into a heuristic query optimizer enables runtime selection of the fastest execution variant, improving overall system efficiency.
- The approach outperforms hardware-agnostic systems like Ocelot, which use the same code across processors, by generating processor-specific, high-performance kernels.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.