Method and system for providing context-sensitive, non-invasive data processing optimization framework

By running-time optimization and compiling the operators of the data search pipeline in the database system, using run-time information and optimization rules, the problem of insufficient code optimization in the existing technology is solved, data retrieval performance and hardware utilization are improved, and data retrieval performance and hardware utilization are achieved. More efficient query processing.

CN119166655AActive Publication Date: 2024-12-20HUAWEI TECH CO LTD
View PDF 22 Cites 0 Cited by

Patent Information

Application Number
CN202411171686.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2021-06-30
Publication Date
2024-12-20
Estimated Expiration
2041-06-30

AI Technical Summary

Technical Problem

When processing multiple types of data sources, existing database systems need to frequently use common logic and for loops, resulting in insufficient code optimization and inefficient efficiency. Due to resource limitations, highly specific code cannot be developed to improve query processing performance.

Method used

By performing run-time optimization and compilation for operators in the data search pipeline, using run-time information and optimization rules to optimize and compile operators, specialized intermediate representation code is generated, thereby improving query processing efficiency.

Benefits of technology

It enables faster data search execution time than unoptimized and compiled operators, improves data retrieval performance and hardware usage, reduces code complexity, and supports a more flexible and scalable data management system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166655A_ABST
    Figure CN119166655A_ABST
Patent Text Reader

Abstract

A method of performing a data search in a data source is provided. By the method, operators of a data search pipeline are optimized and compiled in real time using an operator optimization module that optimizes and compiles an intermediate representation of operators to generate operators optimized for executed data search, taking into account runtime information and optimization rules. According to a query plan determined by runtime information and optimization rules, the method can be applied to one operator, and can also be applied to multiple operators applied in any order or tree structure.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application. The application number of the original application is 202180098232.3, and the original application date is June 30, 2021. The entire contents of the original application are incorporated into this application by reference. Technical Field

[0002] The present invention relates generally to the field of retrieving and processing information from data sources, and more particularly to methods of retrieving information using operators optimized and compiled based on execution of data searches. Background Art

[0003] As available data becomes more and more, the need to optimize and speed up data search and access becomes greater and greater. Modern database systems can achieve efficient query processing by using cache-efficient algorithms and data structures, but in order to further improve query processing by preventing branch mispredictions and cache misses as much as possible, database operators need to significantly adjust CPU efficiency, which can be achieved by converting database queries into optimized machine code.

[0004] To handle data sources arranged into columns of many different types, any of which may need to be processed at runtime, the data processing pipelines of modern database systems must rely on common logic. To manage the spectrum of data sets to be processed, many for loops are usually generated, nested in branches.

[0005] Typically, to maximize the performance of search execution and use target machine optimizations, a compiler pass can be applied to optimize the code base. For data processing logic, typically written in a programming language or structured query language (SQL), the compiler pass essentially acts as an interpreter for the code base.

[0006] Existing methods generate code based on submitted data processing logic (i.e., SQL statements), however, once the data processing logic is submitted, most of the variable aspects of the processing flow (e.g., data types, number of columns, and statistics) are fixed. Since the code used before optimization is generic, this may generate a large number of unreachable code sections. There is a trade-off because database architects must provide generic coding to achieve flexibility, but they cannot develop highly specific code due to time and resource constraints.

[0007] What is needed are methods and systems that eliminate or reduce one or more limitations of the prior art by optimizing operators in a data search pipeline for each data search.

[0008] This background information is provided for the purpose of revealing information that may be relevant to the present invention. It is not necessary to admit, nor should it be construed, that any of the above information constitutes prior art against the present invention. Summary of the invention

[0009] In some examples of the present invention, operators of a data search pipeline may be prepared by a developer and compiled into intermediate representation (IR) code before invoking a data search. When executing a data search, parameters of the data query and the data query processing engine and optimization rules may be used to optimize the IR-encoded operators of the data query being executed and compile them for the query processing engine hardware being used. In addition, to facilitate optimization, the functions of the operator files to be optimized may be annotated or marked.

[0010] In an embodiment, the data search includes runtime optimization and compilation of pipeline operators, and it can be executed in a shorter time than the time taken for the data search of operators that are not optimized and compiled at runtime. In other words, since the runtime optimization and compilation workflow according to the embodiment can be executed quickly enough, if the data search is performed with a precompiled operator that is not optimized for data search optimization and compilation, the time required for the data search using such runtime optimization and compilation and using the resulting optimized operator is shorter than the time required for such a data search.

[0011] In an embodiment, operators may be configured in a high-level programming language and compiled into an intermediate representation (IR) version. Annotations may be used to mark functions that are specialized when operators are optimized and compiled for data search at runtime. Optimization of operators may use runtime information and optimization rules. When performing a data search, operators required for the data search may be optimized, compiled, and executed to complete the data search.

[0012] The system for performing data search according to an embodiment should be able to compile IR encoding operators using runtime information of a query processing engine performing data search.The system and the query processing engine may be separate entities or combined into one entity with common components.

[0013] Examples of the present invention include a method for performing a data search, the method obtaining at least one operator, runtime information of the data search, an optimization rule, and obtaining at least one optimized and compiled operator by optimizing and compiling at least one operator according to the runtime information of the data search and the optimization rule. Then, the method performs the data search using the at least one optimized and compiled operator.

[0014] In the above examples, the operator may be configured in a high-level programming language and compiled into an intermediate representation code of the at least one operator by a front-end compiler.

[0015] In any of the above examples, the operators may include an annotation marker function that is specialized when at least one operator is optimized and compiled for data searching at runtime.

[0016] In any of the above examples, the runtime information may include data layout.

[0017] In any of the above examples, the runtime information may include data statistics.

[0018] In any of the above examples, the runtime information may include hardware information of the query processing engine.

[0019] In any of the above examples, the optimization rules may include a global algorithm.

[0020] In any of the above examples, the optimization rules may be based on runtime information.

[0021] In any of the above examples, the optimization rules may include an algorithm specific to at least one operator.

[0022] In any of the above examples, optimizing an operator may include applying at least one optimization to the code of the operator to increase efficiency in performing data searches of the operator.

[0023] In any of the above examples, the optimization operator may be executed after the data search is invoked and before the data search is completed, such that executing the data search includes executing at least one optimized operator.

[0024] In any of the above examples, executing the data search may include optimizing and compiling a plurality of operators that may subsequently be executed by the data search according to a query plan defined by the optimization and compilation.

[0025] Some examples of the present invention include a system for performing a data search. The system includes at least one processor, at least one data storage medium, a query processing engine, a compiler, and at least one operator file configured in a programming language; wherein, when executing the query processing engine, the compiler is used to obtain at least one optimized and compiled operator file by optimizing and compiling the at least one operator file according to the runtime information of the data search and according to an optimization rule; and wherein performing the data search includes executing the at least one optimized and compiled operator file.

[0026] In the above example, at least one operator file may be configured in a high-level programming language and compiled into an intermediate representation code before being optimized and executed by the query processing engine.

[0027] In any of the above examples, the system may further include an operator specialization module, the operator specialization module being used to receive at least one operator file and the runtime information from the query processing engine; and being used to optimize and compile at least one operator file based on the runtime information.

[0028] In any of the above examples, the operator file may be configured in a high-level programming language and compiled into an intermediate representation code.

[0029] In any of the above examples, an operator file may include an annotation marker function that is specialized when the operator encoded in the operator file is optimized and compiled for the data search at runtime.

[0030] In any of the above examples, the runtime information may include data layout.

[0031] In any of the above examples, the runtime information may include data statistics.

[0032] In any of the above examples, the runtime information may include hardware information.

[0033] The computer program may include instructions which, when executed by a computer, may cause the computer to perform the above-described method.

[0034] The computer-readable medium may include instructions that, when executed by a computer, may cause the computer to perform the above-described method. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 is a block diagram of a data search processing pipeline according to the prior art.

[0036] Figure 2a is a block diagram of compiling a high-level coded operator into a compiled operator according to the prior art.

[0037] Figure 2b is a block diagram of compiling a high-level coded operator into a compiled operator according to an embodiment of the present invention.

[0038] Figure 3 is a block diagram of a process by which an operator may be specialized for a query according to an embodiment of the present invention.

[0039] Figure 4 is a block diagram of a process by which an operator may be specialized for a query according to an embodiment of the present invention.

[0040] Figure 5a is a block diagram of a method for generating an optimized operator according to an embodiment of the present invention.

[0041] Figure 5bis a block diagram of a data search processing pipeline according to an embodiment of the present invention, wherein optimized operators may be used in the data search processing pipeline.

[0042] Figure 6 is a block diagram of a precompilation flow and a runtime specialization flow for generating optimized operators according to an embodiment of the present invention.

[0043] Figure 7 is a flowchart of a method involved in preparing operators to be used when executing a query according to an embodiment of the present invention.

[0044] Figure 8 is a block diagram of electronic devices within a computing and communications environment that may be used to implement devices and methods according to representative embodiments of the present invention.

[0045] Throughout the drawings, like features are identified by like reference numerals. DETAILED DESCRIPTION

[0046] Modern analytical applications, such as data search and data processing software, can combine multiple functions from different libraries and frameworks to build increasingly complex workflows. In the case of data search applications, functions can be organized into "operators", which can be organized in a sequence, a tree, or a more general query plan. Even if each function or operator can achieve high performance individually, the performance of the combined workflow is often an order of magnitude lower than the hardware limitations. Basically, this is due to the lack of hardware-specific support, the lack of specialized operators for data operations, and the high cost of data transfer. To address the above problems, an embodiment includes a framework for data-intensive applications that can provide multi-level, real-time acceleration, optimization, and compilation to support dynamic user-defined functions.

[0047] The embodiment can be adaptive, flexible and scalable. In addition, it can be gradually integrated into existing frameworks such as openLooKeng and Apache Spark without modifying the front-end application programming interface (API) of the existing framework. The embodiment has the ability to use runtime information as well as out-of-band information to achieve real-time code compilation.

[0048] To retrieve data more efficiently, code generation with query-specific information can be used. For example, code generation can support users in removing conditions, propagating constant offsets, pointers, etc., and using inline virtual function calls.

[0049] Figure 1A data search processing pipeline according to an existing solution is shown. For a given data source 105, a data search can activate an operation pipeline 110, each of which processes the data into a new form until the requested data is generated. For example, the first operation can be to read (115) the data, the second operation can be to filter (120), the third operation can be to project (125), the fourth operation can be to aggregate (130), and the final operation can be to shuffle (135). Each operation can be viewed as a step toward presenting the requested data 140 from the original data set 145 of the data source 105. In some cases, code generation (150) can support users to remove conditions, propagate constant offsets, pointers, etc., and use inline virtual function calls.

[0050] One approach is to support code generation using specific data processing jobs. This may require fewer branches, fewer instructions, and support faster execution. However, the use of expert domain knowledge for such specific code generation is often complex, error-prone, and extremely difficult to debug. After that, in practice, maintaining and extending such query compilers over time may become very difficult, as the complexity of the query compiler code base may increase to unmanageable levels as more and more optimizations are added.

[0051] Embodiments include an architectural framework that makes query optimizers and compilers easier to build and extend, ultimately enabling programmers to create more sustainable compiler-based data management systems and dynamically define and customize the processing of big data. This framework can improve data retrieval performance and hardware utilization, which is not possible with existing solutions.

[0052] Embodiments include a modular query compiler that can be described using several levels of abstraction. Each level of abstraction can be responsible for expressing a subset of optimizations. This can separate the concerns of different types of code optimizations. Further, through multiple levels of abstraction, embodiments can support the gradual transformation of high-level queries into low-level code, thereby supporting a more controlled code generation approach.

[0053] Figure 2a Compiling a high-level coded operator into a compiled operator according to an existing scheme is shown. A high-level (HL) language, such as SQL 205, can be used to create a generic operator code 210 so that the compiled operator 212 can be similar for any query. Neither the initial operator code 210 nor the compiled operator 212 is search dependent. Although Figure 2acan represent a compilation of a single operator, but in practice, an SQL query can generate a series of operators that perform retrieval, filtering, transformation, and perhaps other operations. For example, if a query is to identify from a database employees whose age is less than 25, three operations and corresponding operators may be required: i. retrieve data from the database; ii. filter data by age; iii. filter names from the output of the previous operation.

[0054] Figure 2b Compiling a high-level coded operator into a compiled operator according to an embodiment of the present invention is shown. SQL language 205 or other high-level (HL) code may be used to write operator code 210. However, the present embodiment relates to optimizing operators for a given input data query, and therefore, before fully compiling the operator code 215, information 220 including data types, statistics of the queried data, and SQL parameters may be received by an operator optimizer module 225 and applied to the operator code 210 to optimize the operator for the input data query.

[0055] In one embodiment, the method can be to use real-time compilation so that the operator is optimized and compiled during query execution to generate results faster than if the operator is general or unoptimized. The optimization step can include designing a query plan that describes the operation flow to be applied to the data source by the operator, selecting an algorithm for the operator, generating a specialized operator, and optionally, the user can define how and when to apply the operator in the query plan (i.e., inject the operator). At this point, the database management system executing the query can execute the query plan using the injected optimized operator. In addition, in order to optimize the operator, the embodiment can use runtime information.

[0056] In order to select the operation algorithm, the embodiment can optimize the combination of operators, data structures, access modes and operation parallelism. In order to select the appropriate method, the embodiment can consider various inputs, including information from the data engine that processes the data query, or information from the data search, such as data types, statistical information and SQL parameters. For example, in the operator algorithm, the use of some data types can support the selection of some hash algorithms (i.e., probe operators). This is more efficient than using traditional screening that needs to read a single row. In addition, the embodiment can use statistical information to select the parallelism level and operator fusion mechanism.

[0057] Figure 3The process by which an operator can be specialized for a query according to an embodiment of the present invention is shown. At any time before a data search, an operator for operating on data 302 in a database can be written in high-level (HL) code, such as C, C++, Rust, or another high-level code as a high-level encoding operator 305. It can then be compiled into an intermediate representation (IR) code in a template file called a template or operator.tpl file including an IR encoding operator 310, where the ".tpl" extension refers to the template file type. As IR code, the operator can be received (312) at an operator specialization module 315. When the query processing engine 320 performs a data search 360, it can also trigger the execution of an operator specialization 345, where the operator specialization module 315 can further consider metadata from the data search 360 and from the query processing engine 320 (e.g., a big data engine), which can be a structured query language (SQL) engine 320 that processes (325) the data query. The metadata may include parameters (i.e., "params" or system information) 330 for the query processing engine, data statistics 335 (i.e., statistical information about the data or data search), and the data layout 340 of the data or data search. The IR-encoded operators 310 in the optimizer specialization module 315 may then be customized (i.e., "specialized") for the query by implementing an application programming interface (API) for just-in-time (JIT) compilation and optimization for the data engine 320 and data search 360. This may be referred to as JIT API specialization 350. The result may be a shared in-memory operator file (i.e., operator.so) specialized for the query that may be generated before the data search is completed to improve the efficiency of the data search. The resulting operator.so file including the optimized operator 355 may be placed in the data search pipeline 365 as a specialized operator among other operators 368, which may enable the data processing pipeline to execute faster than if the operator were not specialized. The data processing pipeline may be ordered (e.g., Figure 3 ) or include multiple operators 368 in various other tree structures (not shown) that support generating the final result 370. The optimized operator file 355 can also be shared and used with other similar queries executed in parallel or in the future as needed, and therefore, it can be referred to as an "in-memoryoperator.so" file 355, where the ".so" extension refers to the shared object file type.

[0058] Figure 4 is another illustration of the process by which an operator can be specialized for a query according to an embodiment of the present invention. Initially, the operator can be written in high-level (HL) code such as C++, Rust or other high-level code and is referred to as an HL-encoded operator 305, or more specifically, a "template.c" file, a "template.cpp" file, or a "template.rs" file. It can then be compiled (307) into an intermediate representation (IR) code in a file called a compiled template, which includes an IR-encoded operator 310. These files are not created during data search execution, but are prepared by the developer in anticipation of a data search so that they are ready for further customization when the data search is performed. In other words, the file including the IR-encoded operator can be prepared at any time before the data search, and only when the data search is performed will the IR-encoded operator of the file be optimized and compiled for data search execution. In some embodiments, the HL-encoded operator 305 is prepared (405) into an IR-encoded operator 310, which is ready to be optimized for the expected query so that it can be used by the operator specialization module 315. Embodiments include preparation (405) of the IR encoding operator 310, which may be further optimized in conjunction with optimization (350) of the IR encoding operator 310 for data searching. Embodiments may include an operator specialization module 315 for optimizing the IR encoding operator 310. It should be understood that embodiments may be combined.

[0059] Once the IR encoded operator 310 is prepared (405) for optimization, it can be received (312) by (i.e., loaded into) an operator specialization module 315, which can optimize (350) the IR encoded operator 310 into an operator optimized for data querying or data searching using a given data engine, or in other words, an optimized operator 355.

[0060] In one embodiment, the optimization of the IR encoding operator 310 may be performed in more than one step. One step may be to consider metadata from the query and the query processing engine, i.e., the hardware involved in the search. This step may be referred to as "hardening" 410, essentially optimizing the operator of the hardware of the query processing engine. Hardening involves concretizing, defining, or giving more accurate values ​​to certain variables of the IR encoding operator 310 that were previously unknown. The metadata may include parameters 330 of the data search and query processing hardware being used, statistics 335 of the data search, and data layout 340 of the data search.

[0061] If the IR code includes virtual function references to specific library functions, the compilation process may include replacing the virtual function references with actual code in the library, and the hardening process may be applied after the replacement. The process of hardening (410) may be viewed as input 415 of the metadata from the query to the operator specialization module 315.

[0062] To implement a data search according to an embodiment in which an operator is particularly suited to the search itself, an embodiment may include two complementary workflows. One workflow may be executed during project construction before performing a data search, and it may include the generation of an operator template that is created by a developer to accommodate certain data searches. A subsequent and complementary approach may be executed after the data search but before its completion, and may include optimizing operators based on characteristics of the data search itself. In another embodiment, such optimization based on the data search may be performed and completed in a short period of time between the start of the data search execution and the generation of the results, thereby generating the results using the optimized operator.

[0063] Figure 5a A method for generating an optimized operator according to an embodiment is shown. The method can be viewed as two workflows: a pre-compilation workflow 505 and a runtime specialization workflow 510. As an initial step that can be performed before performing a data search, a developer can create an operator in HL code such as C, C++, Rust, or other HL code. The resulting file can be referred to as an HL-encoded operator 305. Using an operator compiler 515 (e.g., Clang or other), which in turn can use a global compiler 520, the HL-encoded operator 305 can be compiled into an IR-encoded operator 310. In one embodiment, the HL-encoded operator 305 can be written so that once compiled in the IR-encoded operator, it can adapt to various expected data searches from the query processing engine 320. A copy of the IR-encoded operator 310 can be maintained (517) in a pre-optimized state and can be saved to a file or maintained in a registry, such as available on demand for further use.

[0064] At runtime, when a data search is invoked, another workflow may be executed, and it may be identified as a runtime specialization flow 510. When executing a data search, an operator specialization module 315 according to an embodiment may receive (312) an IR encoding operator according to an embodiment. The operator specialization module 315 may also receive metadata from the data search itself, which may be used to specialize (i.e., customize or adapt) the IR encoding operator 310. The metadata may be provided by a query processing engine 320 that executes the data search. The query processing engine 320 may include a metadata manager 525, a statistics manager 530, and a system information manager 535, which may provide data layout 340, data statistics 335, and system information 330, respectively, to the operator specialization module 315 of an embodiment.

[0065] The operator specialization module 315 according to an embodiment may also receive ( 540 ) optimization rules 545 , which may include global algorithms and algorithms specific to some operators.

[0066] In one embodiment, once the operator specialization module 315 receives (312) the IR encoded operator 310, system information 330, data statistics 335, data layout 340, and optimization rules 545, the IR encoded operator 310 can be compiled with a global compiler 520. In one embodiment, the global compiler 520 can be written using an infrastructure such as LLVM 550 or GCC, and an embodiment can also use another compilation infrastructure instead. The compilation process can include applying optimizations to the IR encoded operator 310 that are specific to the received data, and in particular, specific to the data provided by the search requested by the query processing engine 320. Because it is performed after the search request, it can be referred to as just-in-time (JIT) compilation, and because its results can include operators specialized for a specific search request, the compiler can be said to specialize the IR encoded operation for a specific data search. For these reasons, the compilation in this step can be referred to as a step of JIT specializing and compiling (555) the IR encoded operator 310.

[0067] In one embodiment, after the IR-encoded operator is received (213) and just-in-time (JIT) specialized and compiled (555) by the operator specialization module 315, the operator specialization module 315 may again receive (560) the resulting file. The compilation (555) effectively corresponds to the creation of an optimized operator 355. The specialization and compilation (555) may convert the IR-encoded operator into an optimized operator compiled for a specific target hardware 565 of the query processing engine 320, such as a central processing unit (CPU), a graphics processing unit (GPU), a tensor processing unit (TPU), a field programmable gate array (FPGA), or other hardware. The runtime specialization flow 510 according to the described embodiment may take the IR-encoded operator 310 as input and generate an output of an optimized operator 355 that is specialized for data searches performed by the query processing engine 320 and encoded (i.e., compiled) in the machine language of the target query processing engine 320. Furthermore, in embodiments, such generation of optimized operators according to embodiments may take less time than data searches using non-optimized operators according to embodiments.

[0068] Once the optimized operator 355 is generated in the precompilation flow 505 and runtime specialization flow 510 according to an embodiment, it can be used by the query processing engine 320 as part of the pipeline 365 of operators to perform data searches.

[0069] Figure 5b shows the optimized operator and how it can be used in Figure 3 560 , 575 , 580 , 585 , and other operations, and these operations can be performed in various orders or tree structures. In one embodiment, according to one embodiment, the order and tree structure of any one of these operations can be replaced or defined by the optimized operator 355 created (350) by the precompiled flow 505 and the runtime specialization flow 510.

[0070] By optimizing query operations at a very low level (i.e., using IR or machine-level encoding), and therefore optimizing the query itself, embodiments can adapt query execution to the microarchitecture of a specific machine. Queries compiled using such low-level code optimizations also take into account runtime data information and can be considered to be based on machine-level programming. These queries can be classified by a taxonomy that describes their results in terms of communication constraints and other hardware-related constraints.

[0071] Embodiments may include some specialized modules for performing some steps of the runtime specialized flow 510. Further, the precompiled flow 505 and the runtime specialized flow 510 may each process multiple operators simultaneously, not just Figure 5a and Figure 5b An operator is shown in for simplicity.

[0072] Figure 6 A pre-compilation flow 505 and a runtime specialization flow 510 according to an embodiment are shown. To implement an embodiment, a developer may initially configure and write one or more operators in a high-level programming language 305 such as C, C++, Rust, or another programming language. Once written, the developer may use an operator compiler front end 515, such as Clang (depending on the compiler infrastructure used), to compile the HL-encoded operator 305 into an IR-encoded operator 310. In the HL-encoded operator 305, the developer may specify which functions may be involved in the specialization of the operator specialization module 315 by annotating the operator specialization module 315. For example, if the compiler to be used is built with the LLVM infrastructure, the annotation may be a Clang annotation. The annotation may mark the function so that once compiled into the IR-encoded operator 310, the operator specialization module 315 may identify the annotated function during the JIT specialization and compilation phase 555. The specialization process of these functions may be customized programmatically, which maps input and context information to specific optimization rules.

[0073] During the runtime specialization flow 510, the IR-encoded operators 310 called by the query may be received 312 by the operator specialization module 315 using a loading module called an "operator loader" 605. In other words, during query / job execution, the operators required for the query / job are received in IR form ("IR template files") into the IR code module for execution using the operator loader portion of the compiler. When the query processing engine 320 requests a data query or data search, runtime information 610 may also be provided (615) to the operator specialization module 315. In other words, during query / job execution, the query processing engine may provide runtime information about at least one of data layout, data statistics, and system information. This may be generally received (540) by the operator specialization module 315, or more specifically, it may be received (610) by a specialization module called a hardening module 620, as further described below. The runtime information 610 may include information describing the system hardware 330, information about the data layout 340 of the query, and statistical information about the data 335.

[0074] The parameters and variables of the operator specialization module 315 that has received (i.e., loaded with) the IR encoded operator 310 may be replaced with the parameters and variables of the runtime information 610 through a process that may be referred to as hardening 615 and performed by a module referred to as a "hardening module" 620. Since the operator specialization module 315 goes through different stages, each stage may be identified differently, such that when the operator specialization module 315 receives the IR encoded operator 310 through the loading module 605, the operator specialization module may be referred to as an operator IR module, an IR operator module, or simply an IR module 625, and after being hardened (615) with the hardening module 620, it may be referred to as a hardened IR module 630. At this point, compilation 555 may be performed by a just-in-time compilation module, a JIT module 635. The JIT module 635 is a compiler that is used to JIT compile the hardened operator IR module and apply optimizations implemented by rules to further optimize the code, remove unreachable code, remove unnecessary branches, apply function inlining, etc. Because compilation should be performed after initiating a data query, the process of applying optimizations and performing compilation can be referred to as just-in-time (JIT) compilation. During compilation 555, optimizations to IR-encoded operators can take into account optimization rules 545, which can be applied 555 to IR-encoded operators 310 by JIT module 635. Optimization rules 545 can include global configuration and session values, configuration and session values ​​specific to one or more operators, and configuration and session values ​​specific to the target hardware 565 of the query processing engine performing the data search. The operator code (including the optimized operator 355) obtained by optimization and compilation 555 can configure session and hardware values ​​globally or specifically for the operator.

[0075] The optimizations applied (555) to operators in the IR code may include removing unreachable code, removing unnecessary branches, function inlining, and other optimizations. The just-in-time compilation module 635 that performs optimizations on IR-encoded operators may be referred to as a JIT module 635. Figure 6 As shown, the output of the process is one or more optimized operators 355 designed by the developer through the HL code 305 (which is optimized at the IR level according to the optimization rules 545 and the runtime information 610, and compiled (555) for the target hardware 565), that is, one or more optimized operators 355 in the target machine code, which can be used in the processing pipeline 365 of the data search performed by the query processing engine 320.

[0076] Figure 7 is a flowchart of the steps involved in preparing an operator to be used when executing a query according to an embodiment. Initially, the operator specialization module 315 can receive a precompiled IR encoding operator template 312. If step 705 is yes, the received IR encoding operator 310 has a dependency module. A dependency module refers to a static function or library dependency that needs to be generated (i.e., emitted) with the operator. The operator specialization module 315 can also receive (710) a precompiled IR encoding dependency module. If in step 715 specialized values ​​are available for function parameters in the operator, such as data layout information and input / output information, the operator specialization module can replace (720) them with the specialized values. If in step 725, there are specialized statistics 335 for the query's input data (i.e., the data that defines the query being processed), the operator specialization module can replace (730) the predefined statistics values ​​in the empty statistics object in the IR encoding operator.

[0077] The operator specialization module 315 may also receive (735) a global optimization configuration. If an operator specific optimization exists in step 740, the operator specialization module may override (745) the optimization with the operator specific optimization.

[0078] In one embodiment, the operator specialization module can prepare for JIT compilation (750) and update the IR code based on the optimizations defined in the previous steps. The compilation process can include or be supplemented with the removal of unreachable code based on received information (e.g., information from statistics object 755), the removal of unreachable branches, the addition of logic to bypass (i.e., short-circuit) unused portions of code that will not be executed, and other optimizations. If special hardware is involved in the query processing engine in step 760, such as a field programmable gate array (FPGA), a graphics processing unit (GPU), or a tensor processing unit (TPU), the compilation process can include or be supplemented with the generation 760 of machine code for the special hardware. Otherwise, it may be sufficient to generate (765) machine code for a default target (e.g., a local machine).

[0079] The embodiments support the expression of compiler optimizations available in currently existing query compilers, but also support the expression of compiler optimizations that have not yet been developed. More importantly, the embodiments can provide programmers with a great degree of flexibility that is not available in query compilation of existing solutions.

[0080] Embodiments enable integration and support of hardware specific schemes, as well as flexible data processing capabilities, without having to redesign the overall compilation flow of queries.

[0081] Advantages of embodiments may include easy customizability and maintainability of user-defined optimizations. Embodiments may use runtime information 610 to further optimize code 310 , which may ultimately result in better use of hardware resources 565 and faster operation of a cluster of nodes that jeopardizes a big data system 320 .

[0082] Embodiments include using user generated operators 310 that are ready to execute as pre-generated operators that can be dynamically optimized during runtime when performing data searches. This can provide user specific needs and achieve a degree of optimization, flexibility, and user friendliness that is an improvement over prior art general purpose operators.

[0083] Embodiments include a monitoring system for collecting data from queries, jobs, and systems, as well as metadata information of database data that can be consumed by a query optimizer for implementing context-sensitive code generation and for optimizing data processing pipelines.

[0084] Embodiments include a pre-optimizer algorithm that can select appropriate optimization methods and operators for a query based on runtime information collected by a monitoring system.

[0085] Embodiments include second level optimizations for hardware specific contexts to support integration of hardware specific optimization techniques that cannot be achieved by normal means without manual tuning. For example, if any of the CPU, GPU, TPU, or FPGA platforms are available, ready to use, and based on the data to be consumed, the optimizer can use them.

[0086] Embodiments include a combination of the described methods and systems for generating and executing optimized machine code for a selected target via a just-in-time compiler.

[0087] An embodiment may store optimized code including optimized operators according to the embodiment in a cache for possible subsequent reuse.

[0088] Figure 8 950 is a block diagram of an electronic device (ED) 952 shown within a computing and communication environment 950, which can be used to implement the devices and methods disclosed herein. The electronic device 952 typically includes a processor 954, such as a central processing unit (CPU), and may also include a special processor, such as a graphics processing unit (GPU), a tensor processing unit (TPU), a field programmable gate array (FPGA) or other such processors, a memory 956, a network interface 958 and a bus 960 to connect the components of the ED 952. Optionally, the ED 952 may also include components such as a mass storage device 962, a video adapter 964 and an I / O interface 968 (shown in dashed lines). The ED 952 according to an embodiment may also include a cache.

[0089] The memory 956 may include any type of non-transitory system memory that can be read by the processor 954, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), read-only memory (ROM), or a combination thereof. In one embodiment, the memory 956 may include more than one type of memory, such as a ROM used at boot time and a DRAM used to store programs and data when executing programs. The bus 960 may be one or more of any type of several bus architectures including a memory bus or memory controller, a peripheral bus, or a video bus.

[0090] The electronic device 952 may further include one or more network interfaces 958, and the one or more network interfaces 958 may include at least one of a wired network interface and a wireless network interface. Figure 7 As shown, the network interface 958 may include a wired network interface for connecting to a network 974, and may also include a wireless access network interface 972 for connecting to other devices via a wireless link. The network interface 958 supports the electronic device 952 to communicate with a remote entity, such as an entity connected to the network 974.

[0091] The mass storage 962 may include any type of non-transient storage device for storing data, programs, and other information, and making the data, programs, and other information accessible through the bus 960. For example, the mass storage 962 may include one or more of a solid-state drive, a hard disk drive, a magnetic disk drive, or an optical disk drive. In some embodiments, the mass storage 962 may be remote from the electronic device 952 and may be accessed through a network interface such as an interface 958. In the illustrated embodiment, the mass storage 962 is different from the memory 956 including the mass storage 962, and may generally perform storage tasks compatible with higher latency, but volatility is generally low or non-existent. In some embodiments, the mass storage 962 may be integrated with a heterogeneous memory 956.

[0092] In some embodiments, the electronic device 952 may be a stand-alone device, while in other embodiments, the electronic device 952 may be located in a data center. In the art, a data center may be understood as a collection of computing resources (usually in the form of servers) that can be used as collective computing and storage resources. In a data center, multiple servers may be connected together to provide a computing resource pool, on which a virtualized entity may be instantiated. Data centers may be interconnected to form a network including computing and storage resource pools, which are interconnected by connection resources. The connection resources may be physical connections such as Ethernet or optical communication links, and in some embodiments, may also include wireless communication channels. If two different data centers are connected via multiple different communication channels, the links may be combined together using any of a variety of technologies including forming a link aggregation group (LAG). It should be understood that any or all computing resources, storage resources, and connection resources (as well as other resources within the network) may be divided between different subnets, in some cases, in the form of resource slices. If resources across multiple connected data centers or other node collections are sliced, different network slices may be created.

[0093] In an embodiment, the electronic device 952 may be used to compile HL and IR code, to apply optimizations to the IR code, to store data, and to process data queries through a pipeline of operators and / or optimized operators according to an embodiment.

[0094] An example of the present invention includes a method for performing a data search, the method comprising: obtaining at least one operator; obtaining runtime information of the data search; obtaining an optimization rule; obtaining at least one optimized and compiled operator by optimizing and compiling the at least one operator according to the runtime information of the data search and the optimization rule; and performing the data search using the at least one optimized and compiled operator.

[0095] In the above examples, the operator may be configured in a high-level programming language and compiled into an intermediate representation code of the at least one operator by a front-end compiler.

[0096] In any of the above examples, the operators may include an annotation marker function that is specialized when at least one operator is optimized and compiled for data searching at runtime.

[0097] In any of the above examples, the runtime information may include data layout.

[0098] In any of the above examples, the runtime information may include data statistics.

[0099] In any of the above examples, the runtime information may include hardware information of the query processing engine.

[0100] In any of the above examples, the optimization rules may include a global algorithm.

[0101] In any of the above examples, the optimization rules may be based on runtime information.

[0102] In any of the above examples, the optimization rules may include an algorithm specific to at least one operator.

[0103] In any of the above examples, optimizing an operator may include applying at least one optimization to the code of the operator to increase efficiency in performing data searches of the operator.

[0104] In any of the above examples, the optimization operator may be executed after the data search is invoked and before the data search is completed, such that executing the data search includes executing at least one optimized operator.

[0105] In any of the above examples, executing the data search may include optimizing and compiling a plurality of operators that may subsequently be executed by the data search according to a query plan defined by the optimization and compilation.

[0106] Some examples of the present invention include a system for performing data searches, comprising: at least one processor, a data storage medium, a storage medium of a query processing engine, a storage medium of a compiler, and a storage medium of at least one operator file configured in a programming language; wherein, when executing the query processing engine, the compiler is used to obtain at least one optimized and compiled operator file by optimizing and compiling the at least one operator file according to the runtime information of the data search and according to optimization rules; and wherein executing the data search includes executing the at least one optimized and compiled operator file.

[0107] In the above example, at least one operator file may be configured in a high-level programming language and compiled into an intermediate representation code before being optimized and executed by the query processing engine.

[0108] In any of the above examples, the system may further include an operator specialization module, the operator specialization module being used to receive at least one operator file and the runtime information from the query processing engine; and being used to optimize and compile at least one operator file based on the runtime information.

[0109] In any of the above examples, the operator file may be configured in a high-level programming language and compiled into an intermediate representation code.

[0110] In any of the above examples, an operator file may include an annotation marker function that is specialized when the operator encoded in the operator file is optimized and compiled for the data search at runtime.

[0111] In any of the above examples, the runtime information may include data layout.

[0112] In any of the above examples, the runtime information may include data statistics.

[0113] In any of the above examples, the runtime information may include hardware information.

[0114] The computer program may comprise instructions which, when executed by a computer, may cause the computer to perform the method according to any one of claims 1 to 12 .

[0115] The computer-readable medium may include instructions which, when executed by a computer, may cause the computer to perform the method according to any one of claims 1 to 12.

[0116] Embodiments are described above in conjunction with various aspects of the present invention, and these embodiments can be implemented based on these aspects. It will be appreciated by those skilled in the art that embodiments can be implemented in conjunction with the aspects in which they are described, but can also be implemented together with other embodiments of the aspect. When the embodiments are mutually exclusive or incompatible, this is obvious to those skilled in the art. Some embodiments can be described in conjunction with one aspect, but can also be applied to other aspects, which is obvious to those skilled in the art.

[0117] Although the present invention has been described with reference to specific features and embodiments thereof, it is apparent that various modifications and combinations are possible without departing from the scope of the invention. Accordingly, the specification and drawings are to be regarded simply as illustrations of the invention as defined by the appended claims, and are intended to cover any and all modifications, variations, combinations or equivalents that fall within the scope of the invention.

Claims

1. A method for performing data search, characterized in that, The method comprises: Obtain at least one operator, wherein the at least one operator is configured in a high-level programming language and compiled into an intermediate representation code by a front-end compiler; Obtaining runtime information of the data search; Get optimization rules; Optimize and compile the at least one operator according to the runtime information and the optimization rule, and obtain at least one optimized and compiled operator; The data search is performed using the at least one optimized and compiled operator.

2. The method according to claim 1, characterized in that The at least one operator includes an annotation marker function that is specialized when the at least one operator is optimized and compiled for the data search at runtime.

3. The method according to any one of claims 1 to 2, characterized in that The runtime information includes data layout.

4. The method according to any one of claims 1 to 3, characterized in that The runtime information includes data statistics.

5. The method according to any one of claims 1 to 4, characterized in that The runtime information includes hardware information of a query processing engine that executes the data search.

6. The method according to any one of claims 1 to 5, characterized in that The optimization rules include a global algorithm.

7. The method according to any one of claims 1 to 6, characterized in that The optimization rules are based on the runtime information.

8. The method according to any one of claims 1 to 7, characterized in that The optimization rules include an algorithm specific to the at least one operator.

9. The method according to any one of claims 1 to 8, characterized in that Optimizing the at least one operator includes applying at least one optimization to code of the at least one operator, the code increasing efficiency of performing data searches of the at least one operator.

10. The method according to any one of claims 1 to 9, characterized in that Optimizing the at least one operator is performed after invoking a data search and before the data search is completed, such that executing the data search includes executing the at least one optimized operator.

11. The method according to any one of claims 1 to 10, characterized in that Executing a data search includes optimizing and compiling a plurality of operators that are subsequently executed by the data search according to a query plan defined by the data search.

12. A system for performing data search, characterized in that include: at least one processor; at least one storage medium for querying the processing engine, the compiler, and at least one operator file configured in a programming language; Wherein, when executing the query processing engine, the compiler is used to obtain at least one optimized and compiled operator file by optimizing and compiling the at least one operator file according to the runtime information of the data search and according to the optimization rules; and wherein, executing the data search includes executing the at least one optimized and compiled operator file.

13. The system according to claim 12, characterized in that The at least one operator file is configured in a high-level programming language and compiled into an intermediate representation code prior to optimization and execution by the query processing engine.

14. The system according to claim 12 or 13, characterized in that It also includes an operator specialization module, which is used to receive at least one operator file and the runtime information from the query processing engine; and is used to optimize and compile at least one operator file based on the runtime information.

15. The system according to any one of claims 12 to 14, characterized in that Operator files are configured in a high-level programming language and compiled into an intermediate representation code.

16. The system according to any one of claims 12 to 15, characterized in that The operator file includes an annotation marker function that is specialized when the operator encoded in the operator file is optimized and compiled for the data search at runtime.

17. The system according to any one of claims 12 to 15, characterized in that The runtime information includes data layout.

18. The system according to any one of claims 12 to 17, characterized in that The runtime information includes data statistics.

19. The system according to any one of claims 12 to 18, characterized in that The runtime information includes hardware information of the query processing engine.

20. The system according to any one of claims 12 to 19, characterized in that The optimization rules include a global algorithm.

21. The system according to any one of claims 12 to 20, characterized in that The optimization rules are based on the runtime information.

22. The system according to any one of claims 12 to 21, characterized in that The optimization rules include an algorithm specific to the at least one operator.

23. The system according to any one of claims 12 to 22, characterized in that Optimizing the at least one operator is performed after invoking a data search and before the data search is completed, such that executing the data search includes executing the at least one optimized operator.

24. The system according to any one of claims 12 to 23, characterized in that Executing the data search includes optimizing and compiling a plurality of operators that are subsequently executed by the data search according to a query plan defined by the data search.

25. A computer program, characterized in that The computer program comprises instructions which, when executed by a computer, cause the computer to perform the method according to any one of claims 1 to 11.

26. A computer readable medium, characterized in that The computer-readable medium comprises instructions which, when executed by a computer, cause the computer to perform the method according to any one of claims 1 to 11.

Citation Information

Patent Citations

  • State machine expressions in database operators

    CN102323772A

  • Apparatus and method for using parameterized intermediate representation for just-in-time compilation in database query execution engine

    CN107250983A

  • System and method for database query

    CN108027838A

  • Search optimization method and device, electronic equipment and storage medium

    CN112364053A

  • Query system, method executed by query system and computer readable medium

    CN112749143A