Parameterized IR Catalog for Database JIT Compilation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing database query execution engines face inefficiencies and errors in generating intermediate representations (IRs) for just-in-time (JIT) compilation, particularly due to costly and time-consuming code generation processes, which can be error-prone and do not benefit from JIT compilation if the C/C++ code is not specialized for incoming queries.

Innovation Solution

A method and apparatus that identify CPU-intensive functions in database queries, compile them to parameterized IRs with changeable variables, save these IRs in a catalog, and replace parameters with constant values during query execution to generate optimized machine code, thereby avoiding costly run-time generation and enabling efficient JIT compilation.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If LLVM IRBuilder is used to generate intermediate representation at run-time, then JIT compilation can be performed, but the code generation process becomes costly in terms of time and computing resources

Engineering Contradiction:
ImproveJIT compilation capabilityVSAvoidcode generation time
Core Design Contradiction:
ProductivityVSLoss of time

Solution Approach 1:

The patent pre-generates and stores parameterized intermediate representations in a catalog before actual query execution. When a query needs JIT compilation, the system retrieves the pre-generated parameterized IR from the catalog and only performs parameter substitution and constant folding, avoiding the costly process of generating complete query-specific IR from scratch at runtime.

Inventive Principle:
Principle #10Preliminary action

2Ease of manufacture

If C/C++ code is compiled to LLVM IR using clang/clang++, then compilation can be performed, but the code does not benefit from JIT compilation if not specialized for incoming queries

Engineering Contradiction:
Improvecompilation capabilityVSAvoidquery specificity
Core Design Contradiction:
Ease of manufactureVSAdaptability or versatility

Solution Approach 1:

The patent segments the query execution into two parts: a generic parameterized IR template that is pre-compiled, and query-specific parameter values that are substituted at runtime. This allows the system to maintain a reusable compilation infrastructure while achieving query-specific optimization through parameter substitution rather than requiring complete query-specific C/C++ code generation.

Inventive Principle:
Principle #1Segmentation

3Loss of time

If parameterized IR is pre-compiled and stored in catalog, then run-time generation cost is reduced, but the system complexity increases due to catalog management

Engineering Contradiction:
Improverun-time generation timeVSAvoidcatalog management complexity
Core Design Contradiction:
Loss of timeVSDevice complexity

Solution Approach 1:

The patent creates a universal parameterized IR template that can serve multiple different query types through parameter substitution. Instead of maintaining separate compiled IRs for each query type, the system uses a single parameterized template that adapts to different queries by substituting parameters with query-specific values, thereby reducing the number of distinct IR versions that need to be managed in the catalog.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Data Source

PatentEP3254191B1Apparatus and method for using parameterized intermediate representation for just-in-time compilation in database query execution engine
Publication Date: 2020.09.02 HUAWEI TECH CO LTD
  • EP3254191B1 patent drawingFigure 1~2
  • EP3254191B1 patent drawingFigure 3
  • EP3254191B1 patent drawingFigure 4

AI summary

Embodiments are provided herein for using parameterized Intermediate Representation (IR) for just-in-time (JIT) compilation in database query execution engines. In an embodiment, a method supporting query JIT compilation and execution in a database management system includes identifying a central processing unit (CPU) intensive function in a query, and identifying, in the CPU intensive function, one or more parameters. The one or more parameters represent variables with values changeable at different query instances. The CPU intensive function is compiled to a parameterized IR including the one or more parameters. The parameterized IR of the CPU intensive function is saved in a catalog of parameterized IRs.