Online algorithm compilation methods, devices, electronic equipment, and storage media

By using an online algorithm compilation method, an abstract syntax tree is generated and multi-level precise matching and retrieval are performed. This solves the problem of static and fixed algorithm compilation, achieves dynamic adaptation and security isolation, and improves compilation efficiency and resource utilization.

CN123114484APending Publication Date: 2026-11-17PUBLIC METEOROLOGICAL SERVICE CENT OF CHINA METEOROLOGICAL ADMINISTRATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611611514.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-19
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

In existing algorithm development and execution systems, static compilation of algorithms leads to problems such as inability to dynamically adapt, low resource utilization, and insufficient security isolation.

Method used

The algorithm uses an online compilation method to receive computational tasks defined in a declarative domain-specific language, generate an abstract syntax tree and determine the semantic information of the nodes, use unique content fingerprints for multi-level precise matching and retrieval, generate the target executable code, and load it into a secure execution sandbox for isolated execution.

Benefits of technology

It achieves dynamic evolution of the algorithm, efficient compilation and reuse, and secure isolated execution, improving compilation efficiency and resource utilization, and ensuring security in multi-task parallel scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123114484A_ABST
    Figure CN123114484A_ABST
Patent Text Reader

Abstract

This invention provides an online algorithm compilation method, apparatus, electronic device, and storage medium, belonging to the technical field of computer software. The method receives computational tasks defined based on a declarative domain-specific language, achieving a unified abstract representation of the algorithm. By parsing and generating an abstract syntax tree and determining the semantic information of nodes, it provides a foundation for subsequent semantic-based compilation optimization. By generating unique content fingerprints and performing multi-level precise matching searches in a global cache, tasks with the same or similar computational logic can directly reuse existing compilation artifacts, improving compilation efficiency and resource utilization. When multi-level precise matching searches fail, isomorphic mapping compilation is performed in the executable function space based on semantic information, ensuring reliable compilation of new tasks. Finally, the generated target executable code is loaded into a secure execution sandbox for isolated execution.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of computer software, and in particular to an online algorithm compilation method, apparatus, electronic device, and storage medium. Background Technology

[0002] Currently, algorithm development and execution systems typically employ an "offline development-static compilation-deployment and execution" technical paradigm. In this paradigm, algorithms exist as static code files, with compilation and optimization completed before deployment, and are highly dependent on specific development environments, third-party libraries, and hardware configurations. However, this static approach prevents the system from dynamically adapting to changes in input data distribution, hyperparameter adjustments, or model structure searches during runtime. Furthermore, the lack of a unified algorithm abstraction representation and an effective mechanism for reusing computational results necessitates a complete recompilation cycle for even minor algorithm adjustments, resulting in extensive repetitive compilation and redundant computation, leading to low resource utilization. Moreover, existing systems lack sophisticated resource and security isolation mechanisms in multi-task parallel scenarios, making it difficult to guarantee the secure execution of untrusted algorithm code.

[0003] Therefore, there is an urgent need for an online algorithm compilation method that can support dynamic algorithm evolution, efficiently reuse compilation artifacts, and provide secure isolated execution. Summary of the Invention

[0004] To address the problems of static compilation, low resource reuse, and insufficient security isolation in existing technologies, this invention provides an online algorithm compilation method that enables dynamic evolution, efficient compilation and reuse, and secure isolated execution of algorithms.

[0005] In a first aspect, the present invention provides an online algorithm compilation method, applied to a wind and solar power generation prediction platform, the method comprising: It receives computational tasks for predicting power generation based on declarative, domain-specific language definitions. The computational task is parsed to generate an abstract syntax tree, and the semantic information of the nodes in the abstract syntax tree is determined. A unique content fingerprint for the computation task is generated based on the abstract syntax tree, and the unique content fingerprint is used to perform multi-level precise matching and retrieval in the global cache library; If no match is found in the multi-level exact matching search, the target executable code is generated by isomorphic mapping compilation based on the semantic information in the preset executable function space. The target executable code is loaded into a secure execution sandbox for isolated execution, and the execution result is returned.

[0006] Furthermore, it receives computational tasks based on declarative domain-specific language definitions, including: The computational task is formalized as a triplet mathematical object T=(Algorithm,Configuration,Data), where Algorithm is the algorithm structure and constraints described by the declarative domain-specific language, Configuration is the set of configuration parameters, and Data is the data characteristics of the input data. The triplet mathematical object serves as the basic unit for dynamic evolution during runtime. It is used to trigger the recompilation process of the computation task when the configuration parameters or the data characteristics change. The recompilation process employs incremental compilation or full compilation based on the range of change.

[0007] Further, determining the semantic information of nodes in the abstract syntax tree includes: Each node of the abstract syntax tree is assigned a semantic signature, and the semantic signature is used as the semantic information, wherein the semantic signature is used to characterize the mathematical meaning, input / output type and dimensional constraints of the corresponding node; Generate a unique content fingerprint for the computational task based on the abstract syntax tree, including: The abstract syntax tree is normalized and serialized to obtain the algorithm structure string; The algorithm structure string, the standardized representation of the configuration parameters of the computing task, and the summary information of the data features are concatenated. A cryptographic hash algorithm is used to calculate the concatenated data and generate a fixed-length hash value as the unique content fingerprint. The unique content fingerprint is used to identify equivalent tasks with the same calculation logic, the same parameter configuration and the same data characteristics.

[0008] Furthermore, the multi-level exact match retrieval includes: Perform a full-scale exact match retrieval based on the unique content fingerprint in the global cache library; If the full exact match retrieval fails, a binary tree recursive decomposition strategy is used to hierarchically split the abstract syntax tree and extract the subtrees to be matched at different levels. For each level of the subtree to be matched, a corresponding subtree fingerprint is generated, and a precise matching retrieval at the subtree level is performed in the global cache library; If a matching compilation artifact is found, the target executable code is generated by assembling the matching compilation artifact.

[0009] Furthermore, a binary tree recursive decomposition strategy is used to hierarchically segment the abstract syntax tree, including: The root node of the abstract syntax tree is taken as the first-level node, and the set of direct child nodes of the root node is divided into a set of left subtrees and a set of right subtrees, forming the first-level left subtree and the first-level right subtree respectively. If the fingerprints of the first-level subtrees of the first-level left subtree and the first-level right subtree are used for a first-level exact match retrieval in the global cache, and the first-level exact match retrieval fails, then the binary tree splitting operation is recursively performed on the subtrees that failed to match. The set of direct child nodes of the subtrees that failed to match is further divided into a set of left subtrees and a set of right subtrees, until the splitting reaches a preset minimum granularity or the retrieval is successful. The preset minimum granularity is a leaf node or a subtree of a preset level.

[0010] Furthermore, for each level of the subtree to be matched, a corresponding subtree fingerprint is generated, including: The subtree to be matched is normalized and serialized to obtain the subtree structure string; The subtree structure string is cryptographically hashed to generate a fixed-length subtree fingerprint; The subtree fingerprint is used to perform precise matching and retrieval at the subtree level in the global cache library, identifying subtrees with the same computational logic.

[0011] Furthermore, the method also includes: If the full exact match search is successful, then it is determined whether the global cache library stores the final calculation result or the compilation result; If the stored result is the calculation result, then skip the isomorphic mapping compilation and subsequent code execution steps, and directly return the calculation result as the execution result of this calculation task; If the stored result is the compilation result, then the compilation result is used as the target executable code, and the step of loading the target executable code into the secure execution sandbox for isolated execution continues.

[0012] Secondly, the present invention also provides an online algorithm compilation device for use in a wind and solar power generation prediction platform, the device comprising: The receiving unit is used to receive computational tasks for power generation prediction based on a declarative domain-specific language definition; The parsing and determination unit is used to parse the computational task to generate an abstract syntax tree and determine the semantic information of the nodes in the abstract syntax tree; A generation and multi-level exact matching retrieval unit is used to generate a unique content fingerprint of the computation task based on the abstract syntax tree, and to perform multi-level exact matching retrieval in the global cache library using the unique content fingerprint; The isomorphic mapping compilation unit is used to perform isomorphic mapping compilation in a preset executable function space based on the semantic information if no match is found at multiple levels of exact matching retrieval, thereby generating the target executable code. An isolated execution unit is used to load the target executable code into a secure execution sandbox for isolated execution and return the execution result.

[0013] Thirdly, the present invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the computer program to implement the method described in the first aspect.

[0014] Fourthly, the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the method described in the first aspect.

[0015] This invention provides an online algorithm compilation method applied to a wind and solar power generation prediction platform, comprising: receiving a power generation prediction computation task based on a declarative domain-specific language definition; parsing the computation task to generate an abstract syntax tree and determining the semantic information of nodes in the abstract syntax tree; generating a unique content fingerprint of the computation task based on the abstract syntax tree, and using the unique content fingerprint to perform multi-level exact matching retrieval in a global cache library; if the multi-level exact matching retrieval fails, performing isomorphic mapping compilation based on the semantic information in a pre-set executable function space to generate target executable code; loading the target executable code into a secure execution sandbox for isolated execution, and returning the execution result. As described above, the online compilation method of this invention achieves a unified abstract representation of the algorithm by receiving computational tasks based on declarative domain-specific language definitions. This breaks the dependence of traditional static code on specific development environments and hardware configurations, enabling the algorithm to dynamically adapt at runtime. By parsing and generating an abstract syntax tree and determining the semantic information of nodes, a foundation is provided for subsequent semantic-based compilation optimization. By generating unique content fingerprints and performing multi-level precise matching retrieval in a global cache library, tasks with the same or similar computational logic can directly reuse existing compilation products, avoiding the problem of repeated compilation and redundant computation that requires a complete recompilation cycle for any minor algorithm adjustment, significantly improving compilation efficiency and resource utilization. When multi-level precise matching retrieval fails, isomorphic mapping compilation is performed in a pre-defined executable function space based on semantic information, ensuring reliable compilation of new tasks. Finally, the generated target executable code is loaded into a secure execution sandbox for isolated execution, providing refined resource and security isolation guarantees for the operation of untrusted algorithm code in multi-task parallel scenarios. Thus, the overall technical effects of dynamic algorithm evolution, efficient reuse of compilation products, and secure isolated execution are achieved. Attached Figure Description

[0016] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0017] Figure 1 A flowchart of an online algorithm compilation method provided in an embodiment of the present invention; Figure 2 A schematic diagram of an online algorithm compilation device provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0018] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0019] To facilitate understanding of this embodiment, a detailed description of an online algorithm compilation method disclosed in this embodiment of the invention will be provided first.

[0020] Example 1: According to an embodiment of the present invention, an embodiment of an online algorithm compilation method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0021] like Figure 1 As shown, this embodiment provides an online algorithm compilation method, which constructs a complete closed-loop process from algorithm intent declaration to secure execution. It should be understood that, although... Figure 1 The process is shown as linear, but in practical applications, there may be variations such as parallel processing, asynchronous callbacks, or conditional jumps between steps, as long as the core data flow logic is met.

[0022] In step S100, a calculation task for power generation prediction based on a declarative domain-specific language definition is received.

[0023] Specifically, this method is applied to a wind and solar power generation prediction platform. This platform supports online compilation and execution of meteorological forecast correction algorithms and new energy power generation prediction algorithms from multiple R&D units of national and provincial meteorological departments through an online algorithm compilation engine, supporting power prediction services. Of course, this method can also be used for the online compilation of other algorithms; this embodiment of the invention does not impose specific limitations on the above application scenarios. Declarative Domain-Specific Languages ​​(DSLs) differ from traditional imperative programming languages ​​in that their core lies in describing the intent, topology, and constraints of computation, rather than specific sequences of execution instructions. For example, users only need to define the dimension constraints and data types of matrix multiplication, without writing underlying nested loops or memory management code. This expression method completely decouples the algorithm logic from the underlying hardware implementation, allowing the same computation task definition to be independently parsed and optimized on different hardware architectures. By adopting a declarative paradigm, the system can obtain higher-level semantic information, providing a richer analytical foundation for subsequent automated compilation optimization than traditional source code, while also reducing the cognitive burden and technical threshold for cross-platform migration.

[0024] The method of this invention can be used in an online algorithm compilation engine called ForgeCore. This system and the method together constitute a complete technical system for upgrading algorithms from static code to dynamically evolving and securely executable mathematical objects.

[0025] In step S200, the parsing computation task generates an abstract syntax tree and determines the semantic information of the nodes in the abstract syntax tree.

[0026] Specifically, the system's built-in parser transforms declarative code into a structured abstract syntax tree, whose tree structure accurately reflects the logical topology of the computational task. Building upon this, the system further traverses the tree nodes to extract or deduce semantic information, including but not limited to the mathematical meaning of operators, the shape and type constraints of input and output tensors, and data flow dependencies. Determining semantic information is the crucial bridge for transforming the abstract syntax structure into an executable entity; it ensures that the compiler not only knows what the program looks like but also understands what the program represents mathematically. This process provides the necessary context for subsequent isomorphic mappings, guaranteeing that the generated underlying code is functionally strictly consistent with the original declaration.

[0027] In step S300, a unique content fingerprint of the computation task is generated based on the abstract syntax tree, and multi-level precise matching retrieval is performed in the global cache library using the unique content fingerprint.

[0028] Specifically, a unique content fingerprint is a deterministic identifier generated by normalizing the algorithm structure, configuration parameters, and data characteristics. Its core characteristic is that logically equivalent computational tasks will inevitably generate the same fingerprint. This allows the system to manage historical assets by content indexing rather than name or path indexing. The multi-level exact match retrieval mechanism employs a hierarchical search strategy, prioritizing full exact matches based on unique content fingerprints to quickly reuse identical historical results. If no match is found, the abstract syntax tree is hierarchically segmented, and subtree-level exact match retrieval is performed based on the subtree fingerprints of the subtrees to be matched obtained from the hierarchical segmentation. This design maximizes the reusability of compiled artifacts and improves compilation efficiency to the greatest extent possible.

[0029] In step S400, if no match is found in the multi-level exact matching search, isomorphic mapping compilation is performed in the preset executable function space based on semantic information to generate the target executable code.

[0030] Specifically, isomorphic mapping compilation refers to mapping abstract syntax tree nodes to concrete, executable implementations of the underlying hardware while preserving the mathematical semantics. A pre-built executable function space stores verified high-performance computing kernels. For nodes that cannot be directly matched, a just-in-time (JIT) compilation mechanism is triggered to dynamically generate optimized code, ensuring reliable compilation for new tasks.

[0031] In step S500, the target executable code is loaded into a secure execution sandbox for isolated execution, and the execution result is returned.

[0032] Specifically, due to the dynamic and unpredictable nature of code generated through online compilation, running it directly in the host environment poses security risks. The secure execution sandbox provides a resource-constrained and permission-controlled independent runtime environment, effectively preventing malicious code attacks or abnormal programs from damaging the host system. The sandbox dynamically allocates CPU time slices, memory quotas, and I / O permissions based on static code analysis results or runtime profiles, and immediately triggers a circuit breaker upon detecting unauthorized behavior. This mechanism ensures that even in multi-tenant or public cloud environments, the overall stability and security of the system can be maintained, even when executing dynamically compiled code from unknown sources, providing the necessary trust foundation for the large-scale deployment of online algorithm compilation technology.

[0033] Building upon the above, this embodiment further refines the process of receiving computation tasks in step S100. Specifically, receiving computation tasks defined using a declarative domain-specific language includes formalizing the computation task as a triple mathematical object T = (Algorithm, Configuration, Data), where Algorithm is the algorithm structure and constraints described in the declarative domain-specific language, Configuration is the set of configuration parameters, and Data is the data characteristics of the input data. This formal abstraction encapsulates the originally loosely structured code files, configuration files, and data descriptions into a cohesive mathematical entity, enabling the system to parse, store, and schedule computation tasks in a standardized manner. It should be understood that the triple here is not simply a data package, but rather constitutes the smallest atomic unit for all subsequent compilation optimizations and cache reuse. The Algorithm component is typically represented as an abstract syntax tree parsed from a declarative domain-specific language. It precisely describes the computational topology and mathematical semantics without containing specific instruction sequences. The Configuration component is stored in a structured format such as key-value pairs or JSON objects, covering hyperparameters such as learning rate, batch size, and activation function type, as well as runtime environment configurations. The Data component does not directly store massive amounts of raw data but records metadata such as data schema definitions, tensor shapes, data types, and even statistical distribution summaries. This ensures the determinism of fingerprint generation while avoiding the overhead of large-scale data transmission.

[0034] Triple mathematical objects serve as the basic unit of dynamic evolution at runtime. They trigger a recompilation process for computational tasks when configuration parameters or data characteristics change. This recompilation process employs incremental or full compilation based on the range of change. Specifically, the system continuously monitors the state changes of each component of the triple during runtime. Due to the clear dependencies between components within a triple, the system can accurately determine which parts of the algorithm logic are affected by a parameter modification through static analysis or a pre-defined dependency graph. For example, when a hyperparameter in Configuration (such as the regularization coefficient) is adjusted, the system identifies that this parameter is only referenced by the loss calculation subtree in the abstract syntax tree, and is unrelated to the data preprocessing subtree and the model backbone network. In this case, the system only triggers recompilation and re-retrieval for the loss calculation subtree and its downstream nodes, while directly reusing existing compilation artifacts or cached results for the unaffected preprocessing and backbone network parts. This incremental update mechanism based on triple dependency analysis fundamentally changes the traditional compiler's full-scale reconstruction mode where a change in one part affects the entire system.

[0035] Building upon step S200 above, this embodiment further refines the process for determining semantic information and the mechanism for generating unique content fingerprints. Specifically, determining the semantic information of nodes in the abstract syntax tree includes assigning a semantic signature to each node of the abstract syntax tree and using the semantic signature as semantic information. The semantic signature characterizes the mathematical meaning, input / output type, and dimensional constraints of the corresponding node. Unlike traditional compilers that only focus on parsing syntactic structures, the semantic signature introduced in this invention is a structured metadata description designed to eliminate ambiguity in the written form of declarative code, directly addressing the mathematical essence of computational operations. For example, for a matrix multiplication node, its semantic signature not only records the operation type as "MatMul" but also forcibly encodes the shape constraints of the input tensor (such as [N, K] and [K, M]), data type (such as float32 or float16), and whether it is transposed. This refined signature design enables the system to accurately distinguish operations that appear identical on the syntax tree but are fundamentally different in mathematical semantics, such as operations with the same operator but different dimensions, or operations with the same dimension but different precisions. By assigning each node such a mathematical identity card, the system constructs a pure semantic space that is independent of specific variable naming and code formatting, providing a solid semantic benchmark for subsequent accurate matching.

[0036] Building upon this foundation, the process of generating a unique content fingerprint for a computational task based on an abstract syntax tree (AST) is designed as a rigorous deterministic mapping process. This process first normalizes and serializes the AST to obtain the algorithm structure string. Normalization and serialization are crucial preliminary steps to ensure logical equivalence, i.e., identical fingerprints. Their core lies in eliminating all non-semantic differences that do not affect the computational result. Specifically, the system executes a series of normalization rules: for operators that satisfy the commutative law (such as addition and multiplication), their child nodes are forcibly sorted according to the lexicographical order of their semantic signatures, ensuring that A+B and B+A generate identical subtree structures; all local variable names are uniformly renamed (e.g., replaced with v0, v1, v2... according to traversal order) to eliminate string differences caused by different developer naming habits; all comments, whitespace, and redundant nested parentheses are removed; and constant expressions are pre-computed and folded. After these processes, regardless of the variation in the original declarative code's writing style, as long as the expressed algorithmic logic topology is consistent, the resulting algorithm structure string will be unique.

[0037] Subsequently, the system concatenates the algorithm structure string, the standardized representation of the computation task's configuration parameters, and the summary information of the data features. This concatenation strategy embodies the holistic idea of ​​triplet mathematical objects, ensuring that the fingerprint not only reflects the algorithm logic but also binds to the runtime context. In a specific implementation, the concatenated data to be hashed can be represented in the following form: D hash =Serialize(AST)||SortJSON(Config)||Summary(Data) In this implementation, Serialize(AST) represents the normalized algorithm structure string, SortJSON(Config) represents the JSON string of configuration parameters recursively sorted by key name, Summary(Data) represents the schema definition or statistical feature summary of the input data, and the symbol || represents the string concatenation operation. Finally, a cryptographic hash algorithm is used to calculate the concatenated data, generating a fixed-length hash value as a unique content fingerprint. This unique content fingerprint is used to identify equivalent tasks with the same computational logic, parameter configuration, and data characteristics. This embodiment preferably uses the SHA-256 algorithm as the hash function because it has extremely strong collision resistance and avalanche effect; any small change in the input data will lead to a drastic change in the output hash value, thus probabilistically guaranteeing the uniqueness of fingerprints for different tasks. Compared to the traditional MD5 algorithm, SHA-256 provides a higher security margin; and compared to SimHash or MinHash used for fuzzy matching, cryptographic hashing strictly follows the logic of equality, perfectly meeting the stringent correctness requirements of exact matching scenarios. Through this mechanism, the system can compress complex algorithmic tasks into a lightweight, indexable, fixed-length identifier, enabling the global cache library to accurately locate historical computational assets in O(1) time complexity, fundamentally avoiding repeated compilation and redundant computation.

[0038] Building upon step S300 above, this embodiment further refines the overall architecture and execution logic of multi-level exact match retrieval. Specifically, multi-level match retrieval includes full exact match retrieval based on unique content fingerprints in the global cache. This is the first line of defense in the retrieval process and also the fastest path with optimal performance. Since the unique content fingerprint is a fixed-length string generated based on cryptographic hashing, the system can use a hash table or key-value storage engine to complete the search in O(1) time complexity. The core objective of this stage is to capture completely repetitive computational tasks, i.e., scenarios where the algorithm structure, configuration parameters, and data characteristics are strictly consistent. Once a full exact match is hit, the system can be certain that the product in the historical cache is mathematically equivalent to the current task, thereby skipping all subsequent complex compilation processes. This design ensures the ultimate response speed for high-frequency repetitive queries while also ensuring the baseline correctness of the results.

[0039] If a full exact match search fails, a binary tree recursive decomposition strategy is used to hierarchically segment the abstract syntax tree, extracting subtrees to be matched at different levels. This is the second line of defense in the search process, designed to address the challenge of overall task mismatch but reusable local subtrees. In practical applications, users often make local adjustments to the algorithm (such as modifying a certain operator parameter or adjusting a certain layer of network structure), causing changes to the full fingerprint and preventing a full exact match. At this point, the system no longer adheres to overall consistency but instead employs a binary tree recursive decomposition strategy to hierarchically split the abstract syntax tree from top to bottom, extracting subtrees to be matched at different levels. For each subtree to be matched, a corresponding subtree fingerprint is generated, and precise matching retrieval at the subtree level is performed in the global cache. Specifically, this can be done as follows: First, the set of direct child nodes of the root node is divided into a left subtree set and a right subtree set, forming the first-level subtree (including the first-level left subtree and the first-level right subtree). After normalizing and serializing the first-level subtrees, cryptographic hash calculations are performed to obtain the subtree fingerprints, and precise matching retrieval at the first level is performed in the global cache. If the first level does not match, the binary tree splitting operation is recursively performed on the missing subtree, further dividing the set of direct child nodes of the subtree into left and right subtrees. The system recursively divides the data into two subtrees: a first-level subtree fingerprint and a second-level exact match. This process continues until a preset minimum granularity (e.g., a leaf node) or a search hit is achieved. This involves using the root node of the abstract syntax tree as the first-level node, dividing its direct child nodes into left and right subtrees to form the first-level left and right subtrees, respectively. If a first-level exact match is not found in the global cache, the recursive binary tree division operation continues, further dividing the direct child nodes of the unsuccessful subtrees into left and right subtrees again, until a preset minimum granularity (a leaf node or a subtree at a preset level) or a search hit is achieved. This binary tree-based hierarchical strategy allows the system to progressively search for reusable local subtree compilation artifacts while ensuring the correctness of exact matches, significantly improving cache hit rates in scenarios involving local algorithm adjustments.

[0040] If a matching compilation artifact is found, the target executable code is generated by assembling the matching artifact. It is important to note that reusable compilation artifacts have a broad meaning in this invention, and their form is not limited to traditional binary executable files or intermediate representation code. In a preferred embodiment, reusable compilation artifacts may also include cached final computation results from previous tasks. For example, for deterministic computation tasks with pure functions, if the system detects that a task with the same fingerprint has been completed and its results stored, the result can be directly used as the output of the current task, thus completely eliminating the overhead of code loading and execution. In most cases, reusable compilation artifacts refer to optimized machine code, bytecode, or kernel programs for specific hardware accelerators. Regardless of their form, these artifacts have been verified in previous compilation or execution stages. Using them directly as the target executable code or its substitutes not only saves the time cost of just-in-time compilation but also inherits the performance benefits of historical optimization. By constructing this multi-level precise matching retrieval system based on binary tree recursive decomposition, this invention maximizes the reuse value of historical computing assets while ensuring absolute correctness, achieving a dual improvement in compilation efficiency and resource utilization.

[0041] Building upon the subtree-level exact matching retrieval described above, this embodiment further details the subtree fingerprint generation mechanism. Specifically, it generates corresponding subtree fingerprints for each level of the subtree to be matched, including normalizing and serializing the subtrees to be matched to obtain a subtree structure string. This step aims to convert tree-structured data into a deterministic string representation, ensuring that logically equivalent subtrees will necessarily generate the same structure string. The core of normalization and serialization lies in eliminating all non-semantic differences that do not affect the calculation results. In practice, the system executes a series of normalization rules: for operators that satisfy the commutative law (such as addition and multiplication), their child nodes are forcibly sorted according to the lexicographical order of their semantic signatures; all local variable names are uniformly renamed; all comments, whitespace characters, and redundant nested parentheses are removed; and constant expressions are pre-computed and folded. After the above processing, regardless of the variation in the original declarative code writing style, as long as the expressed algorithmic logic topology is consistent, the resulting subtree structure string will be unique.

[0042] Subsequently, the subtree structure string is cryptographically hashed to generate a fixed-length subtree fingerprint. The generation process of this subtree fingerprint is similar to the globally unique content fingerprint generation logic defined earlier, using a cryptographic hash algorithm (such as SHA-256) to calculate the subtree structure string and generate a fixed-length hash value as the subtree fingerprint. This design ensures that the subtree fingerprint has strong collision resistance and avalanche effect; that is, any small change in the input data will lead to a drastic change in the output hash value, thus probabilistically guaranteeing the uniqueness of different subtree fingerprints. Through this mechanism, the system can compress the subtree task at any level into a lightweight, indexable, fixed-length identifier, enabling the global cache library to accurately find historical subtree compiled assets in O(1) time complexity, fundamentally avoiding duplicate compilation and redundant computation.

[0043] Subtree fingerprints are used for precise subtree-level matching and retrieval in the global cache, identifying subtrees with the same computational logic. When storing compilation artifacts, the global cache indexes not only the unique content fingerprints of the entire task but also the subtree fingerprints at each level, thus supporting precise searches at different levels in multi-level matching retrieval. Furthermore, the preset minimum granularity can be a leaf node or a subtree at a preset level, allowing for flexible configuration based on performance requirements and cache hit rates in actual application scenarios. When recursive partitioning reaches the preset minimum granularity but still fails to find a match, the system determines that the subtree has no reusable assets and triggers an isomorphic mapping compilation process to generate new compilation artifacts.

[0044] Based on the aforementioned multi-level matching retrieval mechanism, this embodiment further explains the recursive termination conditions and performance optimization strategies for binary tree recursive decomposition. Specifically, the termination conditions for binary tree recursive decomposition include two cases: First, a search hit occurs, meaning a matching compilation product is found in an exact match retrieval at a certain level. In this case, further splitting of the branch is stopped, and the matching compilation product is returned directly. Second, a preset minimum granularity is reached, meaning that recursive splitting to a leaf node or a preset level still does not result in a match. In this case, splitting is stopped, and isomorphic mapping compilation is triggered. Finally, the partially matching compilation products and the new compilation products generated by the isomorphic mapping compilation process are assembled to generate the target executable code. To optimize retrieval performance, the system can also adopt the following strategies: First, cache hit rate statistics: the system records the cache hit rate of each level of subtree, and can adjust the splitting depth strategy for levels with high hit rates; Second, parallel retrieval: for multiple subtree fingerprints at the same level, the system can initiate cache lookup requests in parallel to reduce overall retrieval latency; Third, adaptive splitting: the system can dynamically adjust the starting level of binary tree splitting according to task complexity, and skip shallow splitting and directly perform deep retrieval for simple tasks.

[0045] To more clearly illustrate the necessity of the binary tree hierarchical precise matching design, a comparative analysis is provided below. While traditional approximate matching schemes can improve cache hit rates, they introduce semantic bias risks, meaning the matching result may have subtle mathematical semantic differences from the current task. This is unacceptable in scenarios with extremely high computational precision requirements, such as weather forecast correction or new energy power generation prediction. This invention employs a multi-level precise matching strategy in the form of a binary tree. Each level of matching is based on a precise comparison of cryptographic hashes, eliminating the possibility of semantic bias at its source. Simultaneously, a recursive decomposition strategy ensures efficient reuse of historical compilation assets even in scenarios involving local algorithm adjustments, achieving an optimal balance between correctness and efficiency.

[0046] Regarding the specific selection of the preset minimum granularity, this invention is not limited to a fixed value. In actual deployment, it can be configured according to the characteristics of the application scenario. For example, for a weather forecast correction algorithm scenario, since the algorithm structure is relatively fixed and changes infrequently, the minimum granularity can be set to a coarser level (such as an intermediate subtree) to maximize cache hit rate; while for a new energy power generation prediction algorithm scenario, since the model structure may be frequently adjusted, the minimum granularity can be set to a finer level (such as a leaf node) to provide finer-grained reuse capability. In addition, the system can also support dynamic adjustment of the minimum granularity parameter at runtime to adapt to the application needs at different stages.

[0047] Following the aforementioned multi-level exact match retrieval hit processing logic, this embodiment further details the assembly mechanism of compiled artifacts after a match. Specifically, when a match is found in an exact match retrieval at a certain level, the system needs to assemble the compiled artifacts obtained from the global cache library with the new compiled artifacts obtained by isomorphic mapping of the parts of the current computing task that are not found in the global cache library, generating complete executable code. This assembly process involves linking operations in the underlying runtime environment. The system first performs an interface compatibility check to ensure that the calling conventions, data formats, and memory layouts of each compiled artifact are consistent. If incompatibility exists, adaptation code is inserted for conversion. Subsequently, the compiled artifacts are linked in memory to form a complete, loadable executable entity. Through this binary tree-based hierarchical exact match-based compiled artifact assembly mechanism, the system successfully decentralizes the reuse granularity of historical compiled assets from the entire task to the subtree level, significantly improving the efficiency and resource utilization of online compilation while ensuring the absolute correctness of the calculation results.

[0048] To more clearly illustrate the technical effects of this embodiment, an online compilation scenario for a weather forecast correction algorithm is used as an example. In this scenario, the national and provincial integrated wind and solar power generation prediction platform (i.e., the wind and solar power generation prediction platform) needs to support the online compilation and execution of weather forecast correction algorithm results from multiple research and development units. Assume that a research and development unit has made local parameter adjustments to its forecast correction algorithm (such as modifying a certain deviation correction coefficient), causing a change in the full fingerprint (i.e., unique content fingerprint), making full exact matching impossible. In this case, the system adopts a binary tree recursive decomposition strategy. First, it performs a first-level segmentation on the root node, finding that most subtrees already have matching records in the global cache, with only a few subtrees missing. The system continues to perform second-level and third-level recursive segmentation on the missing subtrees until the smallest code unit that has changed is located. Experiments show that in a typical weather forecast correction algorithm scenario, compared to the full compilation scheme, the binary tree hierarchical exact matching strategy can reduce the average compilation time by more than an order of magnitude, while ensuring the mathematical correctness of all calculation results.

[0049] Furthermore, the method in this embodiment is particularly applicable to the practical application scenarios of the China Meteorological Administration's integrated national and provincial wind and solar power generation prediction platform. This platform needs to integrate meteorological forecast correction algorithms and new energy power generation prediction algorithms from multiple research and development units. These algorithms are often implemented by different teams with different coding styles and frameworks, but the underlying computational logic may contain a large number of duplicate or similar modules. Through the binary tree hierarchical precise matching retrieval mechanism provided by this invention, the system can automatically identify and reuse the compilation products of these duplicate or similar algorithm modules, without needing to concern itself with differences in upper-level code writing styles, thereby significantly improving the platform's integration efficiency and compilation throughput for multi-source algorithm results. Simultaneously, because precise matching rather than approximate matching is used, the system ensures that the calculation results of all reused products are strictly correct, which is crucial for serious operational scenarios involving the fusion of national and provincial meteorological data and power prediction.

[0050] In step S400 above, if multi-level exact matching searches fail, isomorphic mapping compilation is performed in the pre-defined executable function space based on semantic information to generate the target executable code. This embodiment elaborates on the specific implementation mechanism of this step. Specifically, isomorphic mapping compilation refers to mapping abstract syntax tree nodes to concrete implementations executable by the underlying hardware while maintaining mathematical semantics. The pre-defined executable function space stores verified high-performance computing kernels and their corresponding semantic descriptions. The compiler first attempts to find ready-made code snippets in this space that semantically match the current node; for new logic that cannot be directly matched, the just-in-time compilation mechanism is triggered to dynamically generate optimized code. This mechanism enables the self-evolution of the knowledge base. As the system runtime increases, the executable function space becomes increasingly rich, and the compilation time for subsequent identical or similar patterns will continue to decrease, thereby gradually approaching the performance limit of manual optimization while ensuring flexibility.

[0051] After constructing the aforementioned indexing system, the compilation process enters the substantive search phase. The system traverses the nodes of the abstract syntax tree, using the semantic signatures of the nodes to perform exact matching in the executable function space. This traversal typically employs a post-order traversal strategy, processing leaf nodes before their parent nodes to ensure that, when processing complex operators, their dependent subexpressions have been parsed or confirmed to exist. Since the semantic signatures have been normalized to eliminate all non-semantic differences, this exact matching is mathematically equivalent to verifying computational logical equivalence. If the semantic signature of the current AST node is completely identical to the index key of an entry in the executable function space, it can be concluded that the two are functionally interchangeable. If a matching executable function entry is found, the corresponding pre-compiled code fragment is directly referenced as the target executable code. This path is a fast track for isomorphic mapping compilation, with a time complexity equivalent to only one hash table lookup or B+ tree index lookup, far lower than traditional compilation processes.

[0052] However, algorithmic innovation always precedes the coverage of the knowledge base. For entirely new computational logic, the system must possess the ability to generate code autonomously. If no matching executable function entry is found, the just-in-time (JIT) compiler is invoked to dynamically generate underlying code based on the semantic signature of the node, and the newly generated code fragment is registered as the target executable code in the executable function space. This is the key step in achieving the self-evolutionary characteristic of this invention. Unlike traditional JIT compilers that only focus on the current execution, the JIT compiler in this embodiment uses the semantic signature as the context constraint and target identifier for generation. On the one hand, the static information such as dimension and type carried in the semantic signature enables JIT to generate specialized code rather than general code; on the other hand, after the code is generated and undergoes basic correctness verification, the system automatically serializes it and writes it into the executable function space, establishing a new semantic signature-binary code mapping relationship. This means that the first user to trigger a new algorithm mode needs to pay a one-time cost for JIT compilation, but all subsequent identical or equivalent requests will directly hit the cache, enjoying zero compilation latency and high-performance execution.

[0053] To more clearly illustrate the technical effects of this embodiment, a specific deep learning model fine-tuning scenario is used as an example. Assume a user is training an image classification model. The initial version uses the ReLU activation function, and the system has generated and cached an optimized CUDA kernel for it. In subsequent experiments, the user only replaces the activation function of the intermediate layers of the network with GELU, keeping the rest of the structure unchanged. At this point, the system uses a binary tree recursive decomposition strategy to first perform hierarchical segmentation of the algorithm structure, accurately locating the subtree containing only one activation function node that has changed. The remaining hundreds of convolution, normalization, and connection nodes are precisely matched and hit in the global cache. Then, the system only needs to perform a micro-recompilation on the changed subtree, taking less than 5 milliseconds. In contrast, if a traditional full recompilation scheme is used, even with incremental compilation technology, the entire computation graph needs to be re-parsed, all operators scheduled, and global optimization performed, typically taking hundreds of milliseconds to seconds. This embodiment employs a strategy that combines binary tree hierarchical precise matching with local recompilation. While ensuring the mathematical equivalence of the computation results, it reduces the latency of dynamic adaptation by two orders of magnitude, making the compilation overhead in high-frequency iterative scenarios such as online hyperparameter search and neural architecture search almost negligible.

[0054] Building upon the multi-level exact match retrieval described above, this embodiment further refines the response strategy after a cache hit. Specifically, after performing a multi-level exact match retrieval in the global cache using unique content fingerprints, if a full exact match retrieval is successful, it determines whether the global cache stores the final calculation result or the compilation result. This determination logic constitutes a key watershed for system performance optimization. In specific implementation, each entry in the global cache contains a type identifier field, used to explicitly distinguish whether the entry stores directly returnable business data (i.e., calculation results) or binary instructions that need to be loaded and executed (i.e., compilation results). When an exact match is successful, the system first reads the type identifier. If the stored result is a calculation result, it skips isomorphic mapping compilation and subsequent code execution steps, directly returning the calculation result as the execution result of this calculation task. This path is called the zero-computation fast track. Its applicability is predicated on the calculation task being marked as a pure function, meaning that the same input will necessarily produce the same output, and no external side effects (such as file writing, network requests, or global state modifications). In the definition of declarative domain-specific languages, users can explicitly declare the pure function properties of a task using keywords, or the system can automatically infer them through static data flow analysis when parsing the abstract syntax tree. For example, for normalization operations in image preprocessing, statistical calculations in feature engineering, or deterministic inference tasks in mathematical models, as long as the fingerprint of the input data is completely consistent with the configuration parameters, the system can be certain that the results of the historical cache are strictly equivalent to the current request mathematically. At this time, the system only needs to perform one memory copy or pass-by-reference operation to directly bind the result object in the cache to the output handle of the current task. The time complexity of the whole process is O(1), completely avoiding the overhead of code loading, sandbox initialization, and CPU / GPU computation.

[0055] If the global cache library stores the compilation result, the compilation result is used as the target executable code, and the process continues by loading the target executable code into a secure execution sandbox for isolated execution. This path is suitable for scenarios where the algorithm logic and configuration are exactly the same, but the original data cannot be cached due to side effects, reliance on external real-time state, or privacy compliance requirements. For example, a training task involving database writes, or an inference task that processes sensitive personal information and whose protocol prohibits the persistence of intermediate results. In this case, the system reuses the verified and optimized executable code entity, rather than the business data itself. Although it still needs to go through sandbox loading and runtime execution, it still has a significant performance improvement compared to cold start because it skips the time-consuming just-in-time compilation and linking process. It should be understood that the design of this hierarchical response mechanism is essentially seeking a dynamic balance between storage for time and security / compliance. For high-frequency, repetitive deterministic queries, direct result return can compress end-to-end latency from milliseconds to microseconds; while for stateful or sensitive tasks, code reuse eliminates compilation bottlenecks while ensuring a bottom line of security.

[0056] Building upon step S500 above, this embodiment further refines the construction and operation mechanism of the secure execution sandbox. Specifically, the process of loading the target executable code into the secure execution sandbox for isolated execution first includes instantiating an independent runtime environment as the secure execution sandbox for the computation task. This independent runtime environment is the physical foundation for ensuring the secure execution of algorithms in a multi-tenant environment. In practical implementation, the system can dynamically select different isolation technology stacks based on the security level and performance sensitivity of the task. For highly security-sensitive, untrusted third-party code, lightweight virtualization technologies (such as gVisor or Kata Containers) are preferred. By implementing kernel proxies or microkernels in user space, direct interaction between the container and the host kernel is completely blocked, thus defending against container escape attacks. For internally trusted tasks requiring resource isolation, standard Linux container technologies (such as Docker or LXC) can be used, leveraging namespaces and control groups to achieve process-level isolation, resulting in lower startup latency and higher I / O throughput. For extremely lightweight pure computation functions, the WebAssembly runtime can be used as a sandbox carrier, utilizing its memory safety features and instruction set sandboxing capabilities to complete instance creation within milliseconds. This layered instantiation strategy allows the system to achieve the best balance between security and operational efficiency, avoiding the resource waste caused by a one-size-fits-all approach to heavy virtualization.

[0057] After the sandbox instance is created, the system does not apply the general default security configuration. Instead, based on the principle of least privilege, it analyzes the execution characteristics of the target executable code or the resource requirements of the computational task to generate a targeted resource access policy. This is the core innovation of this invention, distinguishing it from traditional general sandboxes. Specifically, the policy generation logic includes two dimensions: First, whitelist derivation based on static code analysis. During the compilation stage or before loading, the system performs control flow and data flow analysis on the target executable code, or parses the semantic signature of its abstract syntax tree, accurately extracting the actual set of system calls, file path patterns, and network port ranges that the code depends on. For example, for a pure mathematical algorithm that only involves matrix operations, the analysis results will show that it only requires basic memory and I / O calls such as mmap, read, and write, and does not require high-risk calls such as socket, execve, or fork. Second, resource prediction based on historical profiles. If the current task hits the cache or belongs to a known algorithm variant, the system can retrieve historical execution telemetry data (such as peak CPU utilization, memory resident set size, and execution duration distribution) for the task or similar tasks from the global cache library. Based on this data, a dynamic quota slightly higher than the historical peak is set, rather than blindly allocating excessively redundant resources. Through this on-demand weighting strategy generation mechanism, the system compresses the attack surface of each sandbox to a theoretical minimum. Even if there is potential malicious logic or vulnerabilities in the code, they cannot be exploited due to the lack of necessary system privileges and resource support.

[0058] Based on the generated targeted resource access policies, the system configures restricted CPU time slices and memory quotas for the secure execution sandbox, and sets blocking rules for file system writes and external network access for the target executable code within the secure execution sandbox. At the resource configuration level, the system uses the operating system's underlying control group mechanism to strictly limit CPU utilization to the policy-specified quota (e.g., 50% of a single core's time slice), and sets the memory limit to 1.2 times the predicted value as a safety buffer. Simultaneously, it adjusts the OOM Score to ensure that the sandbox process is prioritized for reclamation when host memory is low. At the access blocking level, the file system employs a layered mounting strategy: code directories and read-only data volumes are mounted in read-only mode; temporary data writes are redirected to the memory file system or a separate temporary volume, which is automatically erased when the sandbox is destroyed. Network access is finely controlled through kernel-level packet filtering rules or eBPF programs, allowing only specific IPs and ports on the policy whitelist, while all other inbound and outbound traffic is silently dropped. This deep resource and permission constraint physically eliminates the possibility of malicious code engaging in cryptocurrency mining, lateral movement attacks, or data theft, ensuring that even if a single task is compromised, the entire platform will not be affected.

[0059] Finally, during the loading and execution of the target executable code within the secure execution sandbox, the system monitors the target executable code's behavior in real time. If it detects that the target executable code is performing unauthorized operations or exceeding resource quotas, execution is immediately terminated. Runtime monitoring is the last line of defense for security. In practice, the system uses a system call filtering mechanism (such as seccomp-bpf) to intercept all system calls at the kernel entry point and compares them with a pre-generated whitelist. Any call attempt not on the whitelist is recorded as a violation, triggering an alarm or direct blocking depending on the severity. Simultaneously, a resource monitoring daemon checks the sandbox's CPU, memory, and I / O usage with high-frequency sampling. Once a momentary over-limit or abnormal spike pattern is detected (such as frequent requests for large blocks of memory within a short period), it is determined to be a potential resource abuse or infinite loop attack. When any of the above violations are detected, the system not only sends a SIGKILL signal to the sandbox process to forcibly terminate its execution but also performs cleanup operations simultaneously, including reclaiming child processes, unmounting mount points, deleting temporary files, and releasing network handles to prevent residual resources from being misused by subsequent tasks. Furthermore, the detailed context of each violation (such as the triggered system call number, parameters, and stack trace) is persistently recorded in the security audit log for post-incident tracing and analysis, and for policy optimization. Through this closed-loop mechanism of monitoring-circuit breaking-cleanup-auditing, this invention achieves a security upgrade from passive defense to proactive immunity, providing enterprise-level security for online algorithm compilation and execution, and enabling the running of dynamically compiled code from unknown sources in a multi-tenant public cloud environment.

[0060] Building upon the above, this embodiment further details the dynamic evolution capability of the computation task during execution. Specifically, the method includes pausing the execution of the computation task immediately upon receiving a configuration parameter adjustment instruction or detecting a significant change in data characteristics during the task's execution cycle. This mechanism breaks the static paradigm of the strictly sequential compilation-execution process in traditional compilation systems, giving the system the ability to respond to external changes in real time during runtime. In specific implementation, the system continuously monitors the state of the Configuration and Data components in the triplet mathematical object through an event listener or a polling daemon. Once a change signal is detected (such as a user modifying the learning rate via an API, or an upstream data stream triggering a schema drift), the runtime scheduler sends a suspension signal to the task currently running in the safe execution sandbox. Unlike simple process termination, this pause is accompanied by a complete state saving operation; the system serializes the current register context, stack frame, intermediate tensor buffer, and random number generator state into a recoverable checkpoint snapshot. This state persistence mechanism ensures that subsequent hot code replacements do not lead to the loss of computational context, enabling tasks to resume precisely from the breakpoint after code updates, rather than starting from scratch. This is crucial for long-cycle model training or streaming data processing tasks.

[0061] Subsequently, a new triplet mathematical object is constructed based on the updated configuration parameters or updated data features, and a new unique content fingerprint representing the latest state of the current task is generated. This step reuses the abstraction and fingerprint generation logic defined above, but extends its application from the initialization phase to the runtime phase. Since each component of the triplet has a clear boundary, the system only needs to reserialize the changed components (e.g., only re-encode the new hyperparameter values ​​in the Configuration), without performing a full parsing of the entire algorithm structure. This local update strategy keeps the generation time of the new fingerprint in the microsecond range, far lower than the millisecond or second granularity of task execution, thus ensuring the low-overhead characteristics of the hot update process itself. At the same time, the generation of the new fingerprint (i.e., the new unique content fingerprint) also marks the system's refresh of its task identity recognition, providing a precise version identifier for subsequent differential processing.

[0062] Based on this, the system compares the new unique content fingerprint with the unique content fingerprint of the historical version to locate the changed abstract syntax subtree. This is the core decision-making step for incremental recompilation. Specifically, the system does not simply compare whether two fingerprint strings are equal, but delves into the internal structure of the abstract syntax tree to perform fine-grained diff operations. Since each AST node carries an independent semantic signature and subtree hash value, the system can adopt a top-down recursive comparison strategy: first, compare the root node hash; if they are the same, the entire tree is determined to be unchanged; if they are different, drill down layer by layer to the child nodes until the smallest leaf node or subtree set whose hash value has changed is located. Those subtrees whose hash values ​​remain unchanged are marked as stable regions; while the subtrees whose hash values ​​have changed and their ancestor paths are marked as affected regions. This differential location method based on structured semantics can accurately map the user's modification intention to the smallest set of changes at the code level, avoiding accidental recompilation triggered by text format adjustments or comment modifications of irrelevant nodes, and ensuring the accuracy of incremental updates.

[0063] Next, the unique content fingerprint of the changed abstract syntax subtrees is used to perform multi-level precise matching searches in the global cache library, while existing compilation artifacts are directly reused for unchanged abstract syntax subtrees. This step embodies the ultimate optimization idea of ​​on-demand compilation. For subtrees marked as affected regions, the system treats them as new independent compilation units and sends them into the multi-level precise matching search process to try to find reusable code or results; while for stable regions, the system directly extracts the corresponding compiled machine code and execution state from the runtime memory or local cache of the current task, skipping all search and compilation steps. This hybrid processing mode makes the workload of recompilation linearly positively correlated with the scale of code changes, rather than with the complexity of the entire task. In actual engineering, most runtime adjustments (such as hyperparameter fine-tuning and threshold correction) only affect a very small proportion of nodes in the algorithm graph. Therefore, this mechanism can compress the full recompilation process, which originally required hundreds of milliseconds, to within a few milliseconds, achieving truly seamless hot updates.

[0064] Finally, the target executable code obtained after multi-level precise matching and retrieval is assembled with the reused existing compilation artifacts and loaded into the runtime environment to restore and continue the updated computational task. Code assembly and execution restoration is the final step in the update loop and also the most technically challenging. In practice, the system first unloads the old affected code segment from memory and maps the newly acquired target executable code to the corresponding virtual address space. Since the old and new code may differ in instruction length, register usage, or memory layout, the system needs to perform dynamic linking and relocation operations, updating all jump tables, function pointers, and data references pointing to the code segment to ensure the correct connection between control flow and data flow. Subsequently, the system restores the execution context from the previously saved checkpoint snapshot and sets the program counter to the next valid instruction after the restore point. The entire process is completed atomically within the secure execution sandbox and is completely transparent to external callers. It should be understood that although this embodiment uses the pause-update-resume synchronous mode as an example, in some real-time systems that are extremely sensitive to latency, an asynchronous hot update strategy with double buffering or shadow copies can also be adopted. That is, the new version of the code is built in parallel in the background, and the changes take effect instantly by switching atomic pointers when it is ready, thereby completely eliminating the service interruption window caused by the pause. As long as its core differential compilation and reuse logic is consistent with the present invention.

[0065] Example 2: This invention also provides an online algorithm compilation device, which is mainly used to execute the online algorithm compilation method provided in Embodiment 1 of this invention. The online algorithm compilation device provided in this invention will be described in detail below.

[0066] Figure 2 This is a schematic diagram of an online algorithm compilation device according to an embodiment of the present invention, such as... Figure 2 As shown, the device mainly includes: a receiving unit 10, a parsing and determining unit 20, a generation and multi-level precise matching retrieval unit 30, an isomorphic mapping compilation unit 40, and an isolated execution unit 50, wherein: The receiving unit is used to receive computational tasks for power generation prediction based on a declarative domain-specific language definition; The parsing and determination unit is used to parse the abstract syntax tree generated by the computation task and determine the semantic information of the nodes in the abstract syntax tree; A generation and multi-level exact match retrieval unit is used to generate a unique content fingerprint of the computation task based on the abstract syntax tree, and to perform multi-level exact match retrieval in the global cache using the unique content fingerprint; The isomorphic mapping compilation unit is used to perform isomorphic mapping compilation in a pre-defined executable function space based on semantic information to generate the target executable code if no match is found in multi-level exact matching retrieval. The isolated execution unit is used to load the target executable code into a secure execution sandbox for isolated execution and return the execution result.

[0067] Optionally, the receiving unit is further configured to: formalize the computation task as a triplet mathematical object T=(Algorithm,Configuration,Data), where Algorithm is the algorithm structure and constraints described in a declarative domain-specific language, Configuration is a set of configuration parameters, and Data is the data characteristics of the input data; the triplet mathematical object serves as the basic unit for dynamic evolution at runtime, and is used to trigger the recompilation process of the computation task when the configuration parameters or data characteristics change, wherein the recompilation process adopts incremental compilation or full compilation based on the range of change.

[0068] Optionally, the parsing and determining unit is also used to: assign a semantic signature to each node of the abstract syntax tree and use the semantic signature as semantic information, wherein the semantic signature is used to characterize the mathematical meaning, input and output types and dimensional constraints of the corresponding node; The generation and multi-level exact matching retrieval unit is also used for: normalizing and serializing the abstract syntax tree to obtain the algorithm structure string; concatenating the algorithm structure string, the standardized representation of the configuration parameters of the computation task, and the summary information of the data features; and using a cryptographic hash algorithm to calculate the concatenated data to generate a fixed-length hash value as a unique content fingerprint, wherein the unique content fingerprint is used to identify equivalent tasks with the same computational logic, the same parameter configuration, and the same data features.

[0069] Optionally, the generation and multi-level exact match retrieval unit is also used for: performing a full exact match retrieval based on a unique content fingerprint in the global cache library; if the full exact match retrieval fails, a binary tree recursive decomposition strategy is used to hierarchically split the abstract syntax tree and extract subtrees to be matched at different levels; for each subtree to be matched, a corresponding subtree fingerprint is generated and a subtree-level exact match retrieval is performed in the global cache library; if a matching compilation artifact is found, the target executable code is generated based on the matching compilation artifact.

[0070] Optionally, the generation and multi-level exact match retrieval unit is further configured to: take the root node of the abstract syntax tree as the first-level node, divide the set of direct child nodes of the root node into a set of left subtrees and a set of right subtrees, forming a first-level left subtree and a first-level right subtree respectively; if the fingerprint of the first-level subtree of the first-level left subtree and the first-level right subtree fails to be retrieved in the global cache, the first-level exact match retrieval fails, and the binary tree splitting operation is recursively performed on the failed subtree, dividing the set of direct child nodes of the failed subtree into a set of left subtrees and a set of right subtrees again, until the splitting reaches a preset minimum granularity or the retrieval is successful, where the preset minimum granularity is a leaf node or a subtree of a preset level.

[0071] Optionally, the generation and multi-level exact matching retrieval unit is also used to: normalize and serialize the subtree to be matched to obtain a subtree structure string; perform cryptographic hash calculation on the subtree structure string to generate a fixed-length subtree fingerprint; wherein the subtree fingerprint is used to perform exact matching retrieval at the subtree level in the global cache library to identify subtrees with the same calculation logic.

[0072] Optionally, the generation and multi-level exact match retrieval unit is also used to: if a full exact match retrieval is successful, determine whether the global cache library stores the final calculation result or the compilation result; if it stores the calculation result, skip the isomorphic mapping compilation and subsequent code execution steps, and directly return the calculation result as the execution result of this calculation task; if it stores the compilation result, use the compilation result as the target executable code, and continue to execute the step of loading the target executable code into the safe execution sandbox for isolated execution.

[0073] The device provided in this embodiment of the invention has the same implementation principle and technical effect as the aforementioned method embodiment. For the sake of brevity, any parts not mentioned in the device embodiment can be referred to the corresponding content in the aforementioned method embodiment.

[0074] like Figure 3 As shown in the embodiment of this application, an electronic device 600 includes a processor 601, a memory 602, and a bus. The memory 602 stores machine-readable instructions executable by the processor 601. When the electronic device is running, the processor 601 communicates with the memory 602 via the bus, and the processor 601 executes the machine-readable instructions to perform the steps of the online compilation method of the algorithm described above.

[0075] Specifically, the memory 602 and processor 601 mentioned above can be general-purpose memory and processor, without any specific limitations. When the processor 601 runs the computer program stored in the memory 602, it can execute the above-mentioned online compilation method of the algorithm.

[0076] The processor 601 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 601 or by instructions in software form. The processor 601 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 602, and processor 601 reads the information from memory 602 and, in conjunction with its hardware, completes the steps of the above method.

[0077] Corresponding to the above-described online compilation method for the algorithm, this application embodiment also provides a computer-readable storage medium storing machine-executable instructions. When the machine-executable instructions are called and run by a processor, the machine-executable instructions cause the processor to perform the steps of the above-described online compilation method for the algorithm.

[0078] The online algorithm compilation device provided in this application embodiment can be specific hardware on a device or software or firmware installed on the device. The implementation principle and technical effects of the device provided in this application embodiment are the same as those in the foregoing method embodiments. For the sake of brevity, any parts not mentioned in the device embodiment can be referred to the corresponding content in the foregoing method embodiments. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can all be referred to the corresponding processes in the above method embodiments, and will not be repeated here.

[0079] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.

[0080] For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0081] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0082] In addition, the functional units in the embodiments provided in this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0083] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the online compilation method of the algorithm described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0084] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0085] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The protection scope of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application. All should be covered within the protection scope of this application. Therefore, the protection scope of this application should be determined by the protection scope of the claims.

Claims

1. An online algorithm compilation method, characterized in that, The method, applied to a wind and solar power generation prediction platform, includes: It receives computational tasks for predicting power generation based on declarative, domain-specific language definitions. The computational task is parsed to generate an abstract syntax tree, and the semantic information of the nodes in the abstract syntax tree is determined. A unique content fingerprint for the computation task is generated based on the abstract syntax tree, and the unique content fingerprint is used to perform multi-level precise matching and retrieval in the global cache library; If no match is found in the multi-level exact matching search, the target executable code is generated by isomorphic mapping compilation based on the semantic information in the preset executable function space. The target executable code is loaded into a secure execution sandbox for isolated execution, and the execution result is returned.

2. The method according to claim 1, characterized in that, Accept computational tasks based on declarative, domain-specific language definitions, including: The computational task is formalized as a triplet mathematical object T=(Algorithm,Configuration,Data), where Algorithm is the algorithm structure and constraints described by the declarative domain-specific language, Configuration is the set of configuration parameters, and Data is the data characteristics of the input data. The triplet mathematical object serves as the basic unit for dynamic evolution during runtime. It is used to trigger the recompilation process of the computation task when the configuration parameters or the data characteristics change. The recompilation process employs incremental compilation or full compilation based on the range of change.

3. The method according to claim 1, characterized in that, Determining the semantic information of nodes in the abstract syntax tree includes: Each node of the abstract syntax tree is assigned a semantic signature, and the semantic signature is used as the semantic information, wherein the semantic signature is used to characterize the mathematical meaning, input / output type and dimensional constraints of the corresponding node; Generate a unique content fingerprint for the computational task based on the abstract syntax tree, including: The abstract syntax tree is normalized and serialized to obtain the algorithm structure string; The algorithm structure string, the standardized representation of the configuration parameters of the computing task, and the summary information of the data features are concatenated. A cryptographic hash algorithm is used to calculate the concatenated data and generate a fixed-length hash value as the unique content fingerprint. The unique content fingerprint is used to identify equivalent tasks with the same calculation logic, the same parameter configuration and the same data characteristics.

4. The method according to claim 1, characterized in that, The multi-level exact match retrieval includes: Perform a full-scale exact match retrieval based on the unique content fingerprint in the global cache library; If the full exact match retrieval fails, a binary tree recursive decomposition strategy is used to hierarchically split the abstract syntax tree and extract the subtrees to be matched at different levels. For each level of the subtree to be matched, a corresponding subtree fingerprint is generated, and a precise matching retrieval at the subtree level is performed in the global cache library; If a matching compilation artifact is found, the target executable code is generated by assembling the matching compilation artifact.

5. The method according to claim 4, characterized in that, The abstract syntax tree is hierarchically segmented using a binary tree recursive decomposition strategy, including: The root node of the abstract syntax tree is taken as the first-level node, and the set of direct child nodes of the root node is divided into a set of left subtrees and a set of right subtrees, forming the first-level left subtree and the first-level right subtree respectively. If the fingerprints of the first-level subtrees of the first-level left subtree and the first-level right subtree are used for a first-level exact match retrieval in the global cache, and the first-level exact match retrieval fails, then the binary tree splitting operation is recursively performed on the subtrees that failed to match. The set of direct child nodes of the subtrees that failed to match is further divided into a set of left subtrees and a set of right subtrees, until the splitting reaches a preset minimum granularity or the retrieval is successful. The preset minimum granularity is a leaf node or a subtree of a preset level.

6. The method according to claim 4, characterized in that, For each level of the subtree to be matched, a corresponding subtree fingerprint is generated, including: The subtree to be matched is normalized and serialized to obtain the subtree structure string; The subtree structure string is cryptographically hashed to generate a fixed-length subtree fingerprint; The subtree fingerprint is used to perform precise matching and retrieval at the subtree level in the global cache library, identifying subtrees with the same computational logic.

7. The method according to claim 4, characterized in that, The method further includes: If the full exact match search is successful, then it is determined whether the global cache library stores the final calculation result or the compilation result; If the stored result is the calculation result, then skip the isomorphic mapping compilation and subsequent code execution steps, and directly return the calculation result as the execution result of this calculation task; If the stored result is the compilation result, then the compilation result is used as the target executable code, and the step of loading the target executable code into the secure execution sandbox for isolated execution continues.

8. An online algorithm compilation device, characterized in that, The device, used in a wind and solar power generation prediction platform, includes: The receiving unit is used to receive computational tasks for power generation prediction based on a declarative domain-specific language definition; The parsing and determination unit is used to parse the computational task to generate an abstract syntax tree and determine the semantic information of the nodes in the abstract syntax tree; A generation and multi-level exact matching retrieval unit is used to generate a unique content fingerprint of the computation task based on the abstract syntax tree, and to perform multi-level exact matching retrieval in the global cache library using the unique content fingerprint; The isomorphic mapping compilation unit is used to perform isomorphic mapping compilation in a preset executable function space based on the semantic information if no match is found at multiple levels of exact matching retrieval, thereby generating the target executable code. An isolated execution unit is used to load the target executable code into a secure execution sandbox for isolated execution and return the execution result.

9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, characterized in that, When the processor executes the computer program, it implements the method of any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program thereon, characterized in that, The computer program is executed by the processor to perform the method of any one of claims 1 to 7.