Database Query Compilation Cost Model for Adaptive JIT Selection
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing query compilation methods in database systems face performance degradation for workloads with smaller data sizes due to high JIT compilation costs, necessitating an efficient method to balance code generation and execution time.
Innovation Solution
A cost model is implemented to estimate execution times and compilation costs for different code generation methods, calculating cost savings and selecting the method with the highest savings, which may include optimizations like JIT compilation, register allocation, and loop strength reduction, to determine the most efficient code generation approach for each query.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If JIT compilation is applied to generate optimized code, then execution efficiency is improved, but compilation cost increases
Solution Approach 1:
The system dynamically changes the code generation parameter based on workload characteristics. When data size exceeds a threshold, JIT compilation is enabled to improve execution efficiency; when data size is small, traditional interpretation is used to avoid compilation overhead. This parameter switching resolves the contradiction by adapting the code generation approach to the specific workload conditions.
2Duration of action of moving object
If code generation methods are applied, then execution time is reduced, but compilation overhead increases
Solution Approach 1:
The system implements dynamic selection of code generation methods based on real-time workload assessment. The query compiler evaluates data size and workload characteristics to dynamically choose between JIT compilation, LLVM IR generation, or traditional interpretation. This dynamic approach ensures that compilation overhead is only incurred when it leads to net execution time reduction.
3Adaptability or versatility
If multiple code generation methods are evaluated, then optimal method selection is improved, but system complexity increases
Solution Approach 1:
The system segments the code generation process into distinct evaluable methods (JIT compilation, LLVM IR, traditional interpretation), each with its own cost model. The query compiler evaluates each segment independently based on workload characteristics and selects the optimal one. This segmentation makes the complex selection process manageable and systematic.
Data Source
AI summary
The disclosure relates to technology for query compilation in a database management system. A first execution time of code for at least one database query without applying a code generation method is estimated and in response to receiving the at least one database query, and for one or more code generation methods, a compilation cost and a second execution time of the code as modified by the code generation methods is estimated. A cost savings for each of the one or more code generation methods is calculated, where the cost savings is calculated as the first execution time less the second execution time of the code generation method, less the compilation cost of the code generation method. One of the code generation methods or the no code generation method with the highest cost savings is then selected.


