Batch processing program scheduling optimization method and device, equipment and storage medium
By generating a directed acyclic graph and using reinforcement learning algorithms to optimize the scheduling strategy of batch processing programs, the problems of inefficient and unreliable task scheduling in existing technologies are solved, and efficient and reliable task execution and resource allocation under resource constraints are achieved.
Patent Information
- Application Number
- CN202511003914.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-21
- Publication Date
- 2025-11-07
AI Technical Summary
Existing batch processing scheduling methods cannot effectively guarantee the efficiency and reliability of task scheduling, especially under resource constraints, it is difficult to meet the dependencies and resource constraints between tasks.
By extracting inter-task dependencies and resource requirements from batch processing program code, a directed acyclic graph is generated. Then, a reinforcement learning algorithm is used to minimize the total running time under resource constraints to obtain the target scheduling strategy. Finally, by combining resource constraints, inter-task dependencies, and performance verification, the task execution order and resource allocation are optimized.
It achieves efficient and reliable task scheduling under resource constraints, ensuring that tasks are executed in the correct order, allocating resources reasonably, reducing total runtime, avoiding deadlocks and resource conflicts, and improving the system's flexibility and scalability.
Smart Images

Figure CN120909718A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to computer technology, and particularly to a batch program scheduling optimization method and device, equipment and a storage medium. BACKGROUND
[0002] The existing industry often has batch business processing scenarios, which need to process a large amount of data in the night or at certain specific times. It contains complex processing links and high resource consumption. Whether the processing logic of the batch program can be successfully and efficiently arranged is a key problem for processing batch business. Batch processing program is a program that automatically executes multiple tasks in a set order without human intervention. The existing scheduling method cannot effectively guarantee the efficiency and reliability of task scheduling in batch processing program. SUMMARY
[0003] Embodiments of the present application provide a batch program scheduling optimization method, device, equipment and storage medium to provide an efficient and reliable scheduling strategy under resource constraints, to realize the satisfaction of task dependency and resource constraints, and to minimize the total running time.
[0004] In a first aspect, embodiments of the present application provide a batch program scheduling optimization method, comprising:
[0005] extracting the inter-task dependency relationship and the resource requirement information of each task from the batch processing program code, and generating a directed acyclic graph for representing the task dependency relationship and the resource requirement;
[0006] According to the target agent, the directed acyclic graph is optimized to obtain a target scheduling strategy, wherein the target agent is obtained by minimizing the total running time under the resource constraint condition through the reinforcement learning algorithm, and the target scheduling strategy includes the execution order of all tasks in the directed acyclic graph and the resource allocation information of each task;
[0007] The target scheduling strategy is checked for resource constraints, inter-task dependency relationships and running performance to obtain a target scheduling strategy that meets the requirements.
[0008] In a second aspect, embodiments of the present application also provide a batch program scheduling optimization device, comprising:
[0009] a directed acyclic graph generation module for extracting the inter-task dependency relationship and the resource requirement information of each task from the batch processing program code, and generating a directed acyclic graph for representing the task dependency relationship and the resource requirement;
[0010] a target scheduling policy determination module, configured to perform scheduling optimization on the directed acyclic graph according to a target agent to obtain a target scheduling policy, wherein the target agent is obtained by minimizing total running time under resource constraints through a reinforcement learning algorithm, and the target scheduling policy comprises execution sequences of all tasks in the directed acyclic graph and resource allocation information of each task;
[0011] a target scheduling policy verification module, configured to verify the target scheduling policy in terms of resource constraints, inter-task dependency relationships and running performance to obtain a target scheduling policy meeting requirements.
[0012] In a third aspect, an electronic device is also provided, and the electronic device comprises:
[0013] at least one processor; and
[0014] a memory in communication with the at least one processor; wherein
[0015] the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the batch program scheduling optimization method provided in any of the embodiments of the present application.
[0016] In a fourth aspect, a computer readable storage medium is also provided, and the computer readable storage medium stores computer instructions for enabling a processor to implement the batch program scheduling optimization method provided in any of the embodiments of the present application when the processor executes the computer instructions.
[0017] An embodiment of the above application has the following advantages or beneficial effects:
[0018] By extracting inter-task dependency relationships and resource requirement information of each task from the batch program code and automatically generating a directed acyclic graph for representing the task dependency relationships and resource requirements, a target agent capable of making reasonable scheduling decisions under resource constraints is obtained through a training mode of minimizing total running time under resource constraints through a reinforcement learning algorithm, a reasonable and efficient target scheduling policy is obtained by performing scheduling optimization on the directed acyclic graph according to the target agent, and the target scheduling policy meeting various requirements is finally obtained by verifying the target scheduling policy in terms of resource constraints, inter-task dependency relationships and running performance, thereby ensuring the reliability of the scheduling policy.
[0019] It should be understood that the content described in this section is not intended to identify key or important features of the embodiments of the present application, nor is it used to limit the scope of the present application. Other features of the present application will become apparent through the following description. BRIEF DESCRIPTION OF DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings described below are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.
[0021] Figure 1 is a flow chart of a batch program scheduling optimization method provided by an embodiment of the present application;
[0022] Figure 2 is a flow chart of another batch program scheduling optimization method provided by an embodiment of the present application;
[0023] Figure 3 is a structural schematic diagram of a batch program scheduling optimization device provided by an embodiment of the present application;
[0024] Figure 4 is a structural schematic diagram of an electronic device for implementing the batch program scheduling optimization method of the embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to make the person skilled in the art better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings of the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should be within the scope of protection of the present application.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0027] Figure 1A flowchart of a batch program scheduling optimization method provided by an embodiment of the present application. The embodiment can be applied to the case of optimizing the execution order and resource allocation information of all tasks in a batch program. The method can be performed by a batch program scheduling optimization device, which can be implemented in software and / or hardware, and can be configured in an electronic device. As shown in FIG. 1, the method specifically includes the following steps: Figure 1
[0028] S110, extracting the inter-task dependency relationship and the resource requirement information of each task from the batch program code, and generating a directed acyclic graph for representing the task dependency relationship and the resource requirement.
[0029] The batch program code refers to the processing logic code of the batch program, such as Java program code. Each program in the batch program can be abstracted as a task. The scheduling optimization of the batch degree is the scheduling optimization of the batch tasks. The inter-task dependency relationship refers to the need to depend on the execution result of other tasks when executing a task, such as task A needs to depend on the execution result of task B, so that task A needs to be executed after task B. The resource requirement information of a task refers to the resource information required by the task during execution. For example, the resource requirement information can include but is not limited to hardware resource information, network resource information, and database resource information. The hardware resources include CPU and memory, etc., and are usually related to compute-intensive tasks, representing the computing power required for task execution. Network resources refer to the network bandwidth and network connection required by the task during execution, and are usually related to tasks involving external communication, such as API requests or message passing. The total amount of hardware resources and the total amount of network resources are fixed, and the hardware resources and network resources need to be reasonably allocated during task scheduling to ensure that the resources are not excessively or insufficiently used. Database resources refer to resources required when executing database-related tasks, such as database connections and transactions. Database resources have exclusivity, i.e., a database can only be accessed by one task at a time.
[0030] The directed acyclic graph is a graph structure used to represent the dependency relationship between tasks. The nodes in the directed acyclic graph represent tasks, and the edges represent the dependency relationship between tasks without loops. The dependency relationship between tasks is described in the directed acyclic graph, i.e., which tasks must be completed before other tasks. The directed acyclic graph ensures that tasks are executed in the correct order, avoiding deadlocks and execution errors. It should be noted that there are also nodes without dependency relationships in the directed acyclic graph, i.e., these nodes have no specific execution order, so the execution order of these nodes needs to be optimized.
[0031] Specifically, the batch program code is statically analyzed, that is, without executing the batch program code, the structure and content of the code are directly analyzed, the inter-task dependency relationship and the resource demand information of each task are automatically extracted, and a directed acyclic graph with task dependency relationship and resource demand for scheduling optimization is generated, so that the automatic generation of the directed acyclic graph is realized, and the scheduling optimization efficiency of the batch program is improved. This directed acyclic graph will be used as the input of subsequent scheduling optimization to ensure that each task is executed in the correct dependency order and that the task can be efficiently executed under resource constraints.
[0032] S120, according to the target agent, scheduling optimization is performed on the directed acyclic graph to obtain a target scheduling strategy, wherein the target agent is obtained by minimizing the total running time under resource constraints through a reinforcement learning algorithm, and the target scheduling strategy includes the execution order of all tasks in the directed acyclic graph and the resource allocation information of each task.
[0033] Wherein, reinforcement learning is a machine learning paradigm that aims to learn the optimal policy by interacting with the environment to maximize cumulative rewards. In the processing scenario of batch programs, it is necessary to optimize the task running time and resource allocation in a directed acyclic graph. Each node in the directed acyclic graph represents a task, and its running time and required resources can be estimated in advance. Resources can be divided into three categories: hardware resources, network resources, and database resources. The resource constraint condition can mean that the total amount of all network resources is a constant value, the total amount of all hardware resources is also a constant value, and the database resources have the characteristics of exclusive use (i.e. only one node can occupy the database resources at a time). For this scenario, reinforcement learning methods are applied to optimize the scheduling of batch programs to minimize the total running time and reasonably allocate resources.
[0034] The above scenario is modeled. The batch program scheduling problem is regarded as a resource-constrained optimization problem, where the goal is to minimize the total running time of tasks and reasonably allocate given resources. This problem can be formulated as a Markov decision process, which is solved by a reinforcement learning algorithm.
[0035] Exemplarily, the reinforcement learning process of the target agent can include: at each time step, inputting the current state information into the agent to make action decisions, obtaining the decided current action information; performing the task according to the current action information, and determining the current reward value corresponding to the current action information according to the total running time of all tasks and the resource over-occupation information, and updating the agent according to the current reward value until the training is ended when the convergence condition is met, and the target agent is obtained.
[0036] Wherein, the state is used to describe the characteristics of the environment at a certain time. At each time step t, the current state information S tThe current task state of each task node in the directed acyclic graph and the current total amount of occupied resources can be included. The current task state includes an unexecuted state or an executed state. The current total amount of occupied resources includes a current total amount of occupied hardware resources, a current total amount of occupied network resources, and a node currently occupying database resources (since database resources are exclusive, the current occupation of database resources can be represented by a flag bit). For example, the defined state space is S t =(task state, total amount of occupied resources). The state space includes all important information related to the scheduling process and is the basis for the decision-making of the agent.
[0037] An action refers to a behavior that can be selected by the agent in the current state. At each time step t, the agent needs to select a node for execution and allocate corresponding resources to the node. The current action information can include a target task node selected from the current executable task nodes and resource information allocated to the target task node. The current executable task node can be obtained by screening according to the current total amount of remaining resources and the resource requirement of each current to-be-executed task node, so as to preliminarily ensure the reasonable use of resources. The target task node can be allocated certain hardware resources, network resources, and database resources according to the resource requirement of the target task node. If the target task node requires database resources, the target task node is ensured to obtain the database resources, and it is ensured that the database resources will not be simultaneously occupied by other nodes. For example, the defined action space is A t =(selected node, allocated resource information). Each action represents a reasonable allocation of resources and scheduling of nodes in the current state.
[0038] The reward function is used to determine the optimization goal of the agent at each time step. Since the tasks and resources need to be reasonably scheduled, the running time of the program is minimized, and the waste of resources is avoided, so the reward function can include two parts. One part is to minimize the total running time, that is, the shorter the task completion time, the greater the reward. The other part is the reasonable use of resources, that is, excessive occupation or idling of resources will result in negative rewards, and reasonable allocation of resources is encouraged through rewards to reduce the situation of idling and excessive occupation. Therefore, the reward function Rt can be defined as: R t= -(total running time + λ resource overuse information). Where λ is a weight used to control the impact of resource overuse on the reward. The resource overuse information can be determined according to the resource usage and the resource upper limit. For example, if the resource usage is greater than the resource upper limit, the difference between the resource usage and the resource upper limit is taken as the resource overuse information. If the resource usage is less than or equal to the resource upper limit, the resource overuse information is determined to be 0. When the resource usage exceeds the upper limit, it will be punished, so that the access resources are not reasonably concentrated.
[0039] The state transition function is used to describe the probability distribution of the environment from one state to another state. At each time step t, after performing an action, the system transitions from the current state S t to the next state S t+1 . The state transition depends on the selected node and resource allocation: if a node starts to execute, the state will change, the resource occupation will be updated, and the execution time of the node will also be reduced. If the node execution is completed, the related resources will be released, and a new executable node will be selected. Therefore, the state transition function T(S t , A t ) represents that after performing the action A t , the system transitions from the state S t to the state S t+1 .
[0040] In the embodiments of the present disclosure, the reinforcement learning algorithm can adopt a deep Q network (DQN). When the state space and action space are large, in order to improve the calculation efficiency, the DQN can be used to approximate the Q value function. The DQN represents the Q value function through a neural network, takes the state S t as the input of the neural network, and outputs the Q value corresponding to each action A t . The update formula of the DQN is to optimize the network parameters by minimizing the following loss function: Q(S t , A t ; w) ≈ Q * (S t , A t ), where w is the parameter of the neural network. In order to further improve the performance of the model, a dueling network architecture can be used to decompose the Q value into a state value function and an advantage function: Q(S t , A t ) = V(S t ) + A(S t , A t ), where V(S t ) represents the value of the state. A(S t , A t) represents the advantage of the action. This decomposition improves the efficiency of estimating the value of each action, especially in the case of a large state space, greatly improving the computational efficiency of the model.
[0041] In the training process of reinforcement learning, the agent learns how to reasonably schedule tasks and allocate resources through interaction with the environment. At each time step, the agent selects the optimal action based on the current state and updates according to the reward function. There is a local reward at each time step, and there is also a global reward feedback when all tasks in the directed acyclic graph are scheduled and completed. The agent can automatically adjust the execution order according to the dependency relationship of the tasks, thereby avoiding task deadlocks and execution errors. In this way, the target agent after reinforcement learning can learn to minimize the total running time under resource constraints and reasonably use network, hardware and database resources. That is, the target agent trained can make reasonable scheduling decisions under resource constraints, thereby minimizing the total running time and effectively utilizing various resources. Through the target agent, the execution efficiency of the program can be optimized under complex resource constraints, and the target scheduling strategy output by the target agent is obtained, thereby obtaining the execution order of all tasks in the directed acyclic graph and the resource allocation information of each task, realizing the scheduling optimization of batch tasks. By using the reinforcement learning algorithm, the agent continuously learns and optimizes the scheduling strategy through interaction with the environment. This adaptive ability enables the scheduling system to automatically adjust the optimal scheduling scheme when facing different tasks, resource constraints and scheduling requirements without human intervention, improving the flexibility and scalability of the system.
[0042] Exemplarily, in the reinforcement learning process, the agent selects a target task node from the current executable task nodes according to a target node selection strategy, wherein the target node selection strategy is determined from multiple selectable strategies by an experimental design method; the target node selection strategy includes a first node selection strategy and a second node selection strategy, wherein the first node selection strategy refers to selecting the task node with the longest required running time; the second node selection strategy refers to selecting the task node with the largest amount of task data.
[0043] Specifically, in addition to the first node selection strategy and the second node selection strategy, the optional strategies also include a third node selection strategy and a fourth node selection strategy. The third node selection strategy refers to selecting a task node with the largest ratio of processing time to task data volume, in order to optimize the relationship between processing time and resource consumption. The fourth node selection strategy refers to randomly selecting a task node to explore the solution space other than the optimal solution. The task data volume is used to represent the size of the task. The larger the task data volume, the more resources are required. Since directly using all the optional strategies for node selection will result in excessive computation, affecting the convergence speed of the algorithm, an experimental design method, such as Taguchi experimental design, is used to effectively identify the actions that contribute most to the optimization effect, thereby reducing unnecessary actions. Taguchi experimental design is a statistical method used to identify the most influential factors and optimize through controlled experiments. It helps to reduce the number of actions or configurations that need to be tested, thereby optimizing the learning process by selecting the best combination of actions.
[0044] The optimal two node selection strategies, i.e., the first node selection strategy and the second node selection strategy, are determined from the optional strategies through the experimental design method, thereby effectively reducing the computational complexity and accelerating the convergence of the algorithm. By introducing the "less is more" strategy, the action space is reduced, effectively reducing the computational complexity and significantly improving the efficiency and convergence speed of the algorithm, ensuring that the optimization process is efficient and stable. The "less is more" strategy improves efficiency by reducing the number of actions considered during the learning process. By using fewer actions, the learning process becomes more efficient and the model converges faster.
[0045] S130, checking the target scheduling strategy for resource constraints, inter-task dependency relationships, and running performance to obtain a target scheduling strategy that meets the requirements.
[0046] Specifically, to ensure that the target scheduling strategy optimized through reinforcement learning meets the actual needs of the batch program, the optimization results need to be comprehensively checked. First, the target scheduling strategy is checked for resource constraints, i.e., the resource allocation at each time step is checked to confirm that the total occupancy of network resources and hardware resources does not exceed the total capacity specified by the system. The use of database resources is strictly tested to ensure that only one node can occupy the database resources at any time, thereby avoiding resource conflicts. If the resource constraint condition is not met, the resource allocation needs to be adjusted to ensure compliance with the system resource limits.
[0047] Secondly, the target scheduling strategy is checked for inter-task dependency relationships, i.e., checking whether the target scheduling strategy follows the task dependency relationship in the directed acyclic graph to ensure that each task can only start execution after its dependent tasks are completed. If there is an error in the task order, the target scheduling strategy needs to be adjusted to ensure that the dependency relationship is correctly executed.
[0048] Finally, the target scheduling strategy is checked for running performance, i.e., whether the scheduling result using the target scheduling strategy meets the expected running performance target, especially whether the total running time of the program is minimized. In addition, the usage of resources needs to be evaluated to ensure the rationality of resource allocation and avoid excessive allocation or idle resources. If the scheduling result fails to meet the performance requirements, the target scheduling strategy needs to be adjusted, and the model can be retrained to optimize the result.
[0049] When all the verification steps pass, it is confirmed that the target scheduling strategy meets all the resource, sequence and performance requirements. If one of the verifications fails, it will return to the adjustment stage to modify the resource allocation or scheduling strategy and re-verify until the target scheduling strategy meets all the requirements, thereby ensuring that the scheduling strategy obtained through reinforcement learning not only optimizes the running time and resource occupation, but also strictly follows the resource constraints and task dependency relationships, thereby ensuring that the final obtained scheduling strategy is feasible and effective, and can meet various requirements in actual applications. Through reinforcement learning combined with post-processing verification mechanism, it can more flexibly and efficiently solve the batch program scheduling problem, especially in large-scale and complex resource constraints and task dependency relationships, showing stronger adaptability and optimization ability.
[0050] Through a complete set of preprocessing, reinforcement learning and post-processing processes, batch program scheduling optimization is efficiently and automatically processed, and through the verification of resource constraints, dependency relationships and performance standards, the occurrence of incorrect scheduling is effectively avoided, and the scheme that does not meet the conditions is adjusted in time to ensure that the optimization result meets all the resource, sequence and performance requirements, thereby ensuring the feasibility and optimality of the scheduling result.
[0051] The technical scheme of the embodiment extracts the dependency relationship between tasks and the resource demand information of each task from the batch processing program code, and automatically generates a directed acyclic graph representing the task dependency relationship and resource demand. Through the reinforcement learning algorithm, the total running time is minimized under the resource constraint condition, thereby obtaining a target agent that can make reasonable scheduling decisions under resource constraints. Through the target agent, the directed acyclic graph is optimized for scheduling, thereby obtaining a reasonable and efficient target scheduling strategy. Through the verification of the target scheduling strategy for resource constraints, task dependency relationships and running performance, it is ensured that the finally obtained target scheduling strategy can meet various requirements, thereby ensuring the reliability of the scheduling strategy.
[0052] Figure 2The flowchart of another batch program scheduling optimization method provided by an embodiment of the present application is based on the above embodiments and describes in detail the process of constructing a directed acyclic graph based on batch program code. The explanations of the same or corresponding terms in the above embodiments are not repeated here.
[0053] Referring to Figure 2 The another batch program scheduling optimization method provided by the embodiment specifically includes the following steps.
[0054] S210, parsing all task modules in the batch program code to analyze the method functions called by each task module.
[0055] The task module is a unit with specific functions, such as processing business logic, request response, and database operation. The task module is the basic unit of constructing a directed acyclic graph, and each task module can be regarded as a task node.
[0056] Specifically, all task modules in the batch program code (i.e. JAVA program code) are parsed. In JAVA, the task module generally corresponds to the service layer (such as the class identified by the @Service annotation), the controller layer (such as the class identified by the @RestController annotation and the class identified by the @Controller annotation), and the data access layer (the class identified by the @Repository annotation). The specific parsing process is as follows: the reflection mechanism is used to scan the class annotations in the batch program code to identify all business-related modules (such as @Service, @Repository, @Controller, etc.). Then, the methods in each class are analyzed to identify the specific functions of each method, such as database operation, computation-intensive task, external interface request, etc.
[0057] S220, determining the dependency relationship between tasks according to the method calling relationship and the database access order between task modules, and determining the resource requirement information of each task according to the method functions called by each task module.
[0058] Specifically, the dependency describes that certain task modules must be executed after other task modules are completed. The dependency between task modules can be established through method calls and database access order between task modules. The specific process of analyzing the dependency through method calls is to check whether the methods in each task module call the methods of other task modules to determine whether there is a dependency between the task modules. For example, if the method of task module A calls the method of task module B, task module A must be executed after task module B, that is, task module A depends on task module B. The specific process of analyzing the dependency through database access order is that when processing database resources, the exclusive resource usage needs to be considered additionally. If task module A and task module B both need to use database resources, the dependency between task module A and task module B needs to be determined according to their access order to the database resources. Specifically, on the database operations (such as database query, update, etc.), the execution order between task modules needs to be adjusted according to the operation order. For example, if task module A completes the database operation, task module B can execute the task related to the database, then task module B must be executed after task module A. The database operation can be determined by searching for the @Transactional annotation or by analyzing the method content. The database operation method needs to be scanned to determine which tasks are interacting with the database. Then, according to the order of accessing the database by the operation, dependency relationships are inserted for these tasks to ensure that the order of database resources is followed.
[0059] Each task has different resource requirements according to its function, the amount of data processed, and the execution mode of the task. By analyzing the function of the method called in the task module, it is determined which resource the task model needs and the amount of resource needed is estimated.
[0060] Exemplarily, the "determining resource requirement information of each task according to the function of the method called by each task module" in step S220 can include at least one of the following:
[0061] For each task module, if the task module has a compute-intensive operation, the resource requirement information of the task includes hardware resource information; if the task module has a network interface call or a network transmission request, the resource requirement information of the task includes network resource information; if the task module has a database operation, the resource requirement information of the task includes database resource information.
[0062] Specifically, the resource requirement of a task node can include at least one of hardware resources, network resources and database resources. By analyzing whether there is a compute-intensive operation in the method called by the task module, if there is, it indicates that the task module is a compute-intensive task, i.e., a task involving a large amount of data processing or algorithmic computation. These tasks require more CPU and memory resources. By analyzing the execution complexity and computation amount of the task, the hardware resource requirement of the task module is estimated. By checking whether there is a network request code in the method called by the task module, such as using RestTemplate or similar HTTP request library. These requests indicate that the task requires a certain amount of network bandwidth. By analyzing the places where network interfaces or message queues are called in the code to determine the network resource requirement of the task module. By scanning all methods involving database operations, such as methods marked with @Transactional, database query or modification operation code, etc. For each database operation, by calculating the number of database connections that the operation may require and the frequency of access, the database resource requirement is estimated.
[0063] S230, constructing a directed acyclic graph according to the inter-task dependency relationship, and associating a resource requirement object with each task node in the directed acyclic graph according to the resource requirement information.
[0064] Specifically, each task module is taken as a task node, and the inter-task dependency relationship is taken as an edge, to construct a directed acyclic graph containing all tasks. In each node of the directed acyclic graph, not only the execution order of the task (determined by the dependency relationship between tasks) is included, but also the resource information required by each task, i.e., the hardware resources, network bandwidth and database resources required by the task during execution. Each node can be associated with a resource requirement object, indicating the various resource information required by the node during execution. According to all the extracted dependency relationships and resource requirements, a directed acyclic graph with task execution order and resource constraints is generated. This directed acyclic graph will serve as the input for subsequent scheduling optimization, ensuring that each task is executed in the correct order, and in the case of limited resources, the tasks can be efficiently executed in parallel.
[0065] Exemplarily, after "constructing a directed acyclic graph according to the inter-task dependency relationship" in step S230, it can further include: if there are at least two tasks in the directed acyclic graph that can access the database simultaneously, a virtual database resource management node is inserted in the directed acyclic graph to represent the occupation and release of database resources.
[0066] Specifically, after the directed acyclic graph is generated, it is necessary to ensure that the access to the database resource complies with the exclusivity principle. That is, only one task can access the database resource at the same time. Therefore, additional dependency relationships need to be established between all task nodes that need to access the database resource at the same time. In the directed acyclic graph, if both tasks need the database resource, the execution order of them must be adjusted to ensure that they are not executed at the same time. If task A occupies the database resource during execution, task B must wait for task A to complete before starting execution. If both task A and task B depend on the database resource and task B does not depend on task A, a virtual database resource management node needs to be forcibly inserted in the directed acyclic graph to represent the occupation and release of the database resource, thereby managing the access order of the resource. Only when the database resource is released, can the task be allowed to access the database, thereby guaranteeing the exclusivity of the database resource. When multiple tasks request the database resource at the same time, the database exclusivity ensures that only one task can access the database at a certain time, thereby avoiding conflicts.
[0067] S240, scheduling optimization is performed on the directed acyclic graph according to the target agent to obtain a target scheduling strategy, wherein the target agent is obtained by minimizing the total running time under the resource constraint condition through the reinforcement learning algorithm, and the target scheduling strategy includes the execution order of all tasks in the directed acyclic graph and the resource allocation information of each task.
[0068] S250, the target scheduling strategy is checked for resource constraints, inter-task dependency relationships and running performance to obtain a target scheduling strategy that meets the requirements.
[0069] The technical scheme of the embodiment analyzes the method functions called by each task module by parsing all task modules in the batch processing program code, determines the inter-task dependency relationship according to the method call relationship between the task modules, and determines the resource requirement information of each task according to the method functions called by each task module, thereby automatically generating a directed acyclic graph for representing the task dependency relationship and the resource requirement without human intervention, and improving the scheduling optimization efficiency.
[0070] The following is an embodiment of a batch processing program scheduling optimization device provided by the embodiment of the application. The device and the batch processing program scheduling optimization method of each of the above embodiments belong to the same inventive concept. Details not described in the embodiment of the batch processing program scheduling optimization device can be referred to the embodiment of the batch processing program scheduling optimization method.
[0071] Figure 3 A structure diagram of a batch processing program scheduling optimization device provided by the embodiment of the application. The embodiment can be applied to the case of optimizing the execution order and resource allocation information of all tasks in the batch processing program. As shown in the figure, Figure 3As shown, the apparatus specifically comprises a directed acyclic graph generation module 310, a target scheduling strategy determination module 320 and a target scheduling strategy verification module 330.
[0072] The directed acyclic graph generation module 310 is configured to extract inter-task dependency relationships and resource requirement information of each task from the batch processing program code, and generate a directed acyclic graph for representing the task dependency relationships and the resource requirements; the target scheduling strategy determination module 320 is configured to perform scheduling optimization on the directed acyclic graph according to a target agent to obtain a target scheduling strategy, wherein the target agent is obtained by minimizing total running time under resource constraints through a reinforcement learning algorithm, and the target scheduling strategy comprises execution sequences of all tasks in the directed acyclic graph and resource allocation information of each task; and the target scheduling strategy verification module 330 is configured to verify the target scheduling strategy in terms of resource constraints, inter-task dependency relationships and running performance to obtain a target scheduling strategy meeting requirements.
[0073] The technical scheme of the embodiment extracts inter-task dependency relationships and resource requirement information of each task from the batch processing program code, and automatically generates a directed acyclic graph for representing the task dependency relationships and the resource requirements; the target agent capable of making reasonable scheduling decisions under resource constraints is obtained through a training mode of minimizing total running time under resource constraints through a reinforcement learning algorithm, the reasonable and efficient target scheduling strategy is obtained by performing scheduling optimization on the directed acyclic graph according to the target agent, and the target scheduling strategy meeting various requirements is obtained through verification of the target scheduling strategy in terms of resource constraints, inter-task dependency relationships and running performance, thereby ensuring the reliability of the scheduling strategy.
[0074] Optionally, the directed acyclic graph generation module 310 comprises:
[0075] The task module parsing unit is configured to parse all task modules in the batch processing program code to analyze method functions called by each task module.
[0076] The dependency requirement information determination unit is configured to determine inter-task dependency relationships according to method calling relationships and database access sequences among the task modules, and determine resource requirement information of each task according to method functions called by each task module.
[0077] The directed acyclic graph construction unit is configured to construct a directed acyclic graph according to the inter-task dependency relationships, and associate a resource requirement object with a task node in the directed acyclic graph according to the resource requirement information.
[0078] Optionally, the dependency requirement information determination unit is specifically configured to:
[0079] For each task module, if the task module has a computation-intensive operation, the resource requirement information of the task includes hardware resource information; if the task module has a network interface call or a network transmission request, the resource requirement information of the task includes network resource information; if the task module has a database operation, the resource requirement information of the task includes database resource information.
[0080] Optionally, the directed acyclic graph construction unit is further configured to:
[0081] If there are at least two tasks that can access the database simultaneously in the directed acyclic graph, a virtual database resource management node is inserted in the directed acyclic graph to represent the occupation and release of the database resource.
[0082] Optionally, the apparatus further comprises a reinforcement learning module configured to:
[0083] At each time step, current state information is input into the agent to make an action decision, and current action information is obtained, wherein the current action information includes a target task node selected from the current executable task nodes and resource information allocated to the target task node; the current action information is used to perform a task, a current reward value corresponding to the current action information is determined according to the total running time and resource over-occupation information of all current tasks, and the agent is updated according to the current reward value until a convergence condition is met, and the training is ended, and the target agent is obtained.
[0084] Optionally, the agent is configured to select the target task node from the current executable task nodes according to a target node selection strategy, wherein the target node selection strategy is determined from a plurality of selectable strategies by an experimental design method.
[0085] The target node selection strategy includes the first node selection strategy and the second node selection strategy, wherein the first node selection strategy refers to selecting a task node with the longest required running time, and the second node selection strategy refers to selecting a task node with the largest amount of task data.
[0086] Optionally, the current state information includes a current task state and a current total amount of occupied resources of each task node in the directed acyclic graph.
[0087] The batch processing program scheduling optimization apparatus provided in the embodiments of the present application can execute the batch processing program scheduling optimization method provided in any of the embodiments of the present application, and has the corresponding functional modules and beneficial effects of executing the batch processing program scheduling optimization method.
[0088] It is worth noting that in the above embodiment of the batch processing program scheduling optimization device, each unit and module included is only divided according to functional logic, but is not limited to the above division, as long as the corresponding function can be realized; in addition, the specific name of each functional unit is only for easy mutual differentiation, and does not limit the protection scope of the present application.
[0089] Figure 4 A structural diagram of an electronic device 10 that can be used to implement embodiments of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular telephones, smart phones, wearable devices (e.g., headsets, glasses, watches, etc.), and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit the implementations of the present application described and / or claimed in this document.
[0090] As shown in Figure 4 The electronic device 10 includes at least one processor 11, and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., connected in communication with the at least one processor 11, wherein the memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or loaded into the random access memory (RAM) 13 from the storage unit 18. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0091] A plurality of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunications networks.
[0092] The processor 11 can be various general and / or special purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various batch program scheduling optimization methods and processes described above.
[0093] In some embodiments, the batch program scheduling optimization methods can be implemented as a computer program tangibly embodied in a computer readable storage medium, such as the storage unit 18. In some embodiments, parts or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded onto the RAM 13 and executed by the processor 11, one or more steps of the batch program scheduling optimization methods described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to perform the batch program scheduling optimization methods by any other suitable means, such as by means of firmware.
[0094] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a programmable logic device (PLD), a computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0095] Computer programs used to implement the batch program scheduling optimization methods of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the computer program running on the processor produces the functions / operations specified in the flowcharts and / or the block diagrams. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine as a standalone software package and partially on a remote machine or entirely on a remote machine or server.
[0096] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of a machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0097] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0098] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0099] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.
[0100] It should be understood that the various forms of flow shown above can be used to reorder, add or delete steps. For example, each step described in the present application can be executed in parallel, sequentially or in a different order, as long as the desired results of the technical solutions of the present application can be achieved, which is not limited herein.
[0101] The above detailed description does not constitute a limitation on the protection scope of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A batch processing program scheduling optimization method, characterized in that, The method comprises the following steps: extracting the inter-task dependency relationship and the resource requirement information of each task from the batch processing program code, and generating a directed acyclic graph for representing the task dependency relationship and the resource requirement; scheduling optimization is performed on the directed acyclic graph according to a target agent, so as to obtain a target scheduling strategy, wherein the target agent is obtained by minimizing the total running time under the condition of resource constraints through a reinforcement learning algorithm, and the target scheduling strategy comprises the execution sequence of all tasks in the directed acyclic graph and the resource allocation information of each task; the target scheduling strategy is checked in terms of resource constraints, inter-task dependency relationship and running performance, so as to obtain a target scheduling strategy meeting the requirements.
2. The method of claim 1, wherein, The method for extracting the inter-task dependency relationship and the resource requirement information of each task from the batch processing program code, and generating a directed acyclic graph for representing the task dependency relationship and the resource requirement comprises the following steps: parsing all task modules in the batch processing program code to analyze the method functions called by each task module; determining the inter-task dependency relationship according to the method calling relationship and the database access sequence among the task modules, and determining the resource requirement information of each task according to the method functions called by each task module; constructing a directed acyclic graph according to the inter-task dependency relationship, and associating a resource requirement object with each task node in the directed acyclic graph according to the resource requirement information.
3. The method of claim 2, wherein, The method for determining the resource requirement information of each task according to the method functions called by each task module comprises at least one of the following steps: for each task module, if the task module has a computation-intensive operation, the resource requirement information of the task is determined to comprise hardware resource information; if the task module has a network interface call or a network transmission request, the resource requirement information of the task is determined to comprise network resource information; if the task module has a database operation, the resource requirement information of the task is determined to comprise database resource information.
4. The method of claim 2, wherein, After the directed acyclic graph is constructed according to the inter-task dependency relationship, the method further comprises the following steps: if there are at least two tasks that may simultaneously access a database in the directed acyclic graph, a virtual database resource management node is inserted into the directed acyclic graph, for representing the occupation and release of the database resource.
5. The method of claim 1, wherein, The reinforcement learning process of the target agent comprises the following steps: at each time step, current state information is input into the agent to make a decision on an action, so as to obtain current action information selected from the currently executable task nodes and the resource information allocated to the target task node; task execution is performed according to the current action information, a current reward value corresponding to the current action information is determined according to the total running time and the resource over-occupation information of all current tasks, and the agent is updated according to the current reward value, until the training is ended when a convergence condition is met, so as to obtain the target agent.
6. The method of claim 5, wherein, The agent selects the target task node from the currently executable task nodes according to a target node selection strategy, wherein the target node selection strategy is determined from multiple selectable strategies through an experimental design method. The target node selection strategy includes the first node selection strategy and the second node selection strategy, wherein the first node selection strategy refers to selecting a task node with the longest required running time; and the second node selection strategy refers to selecting a task node with the largest amount of task data.
7. The method of claim 5, wherein, The current state information includes a current task state and a current total amount of occupied resources of each task node in the directed acyclic graph.
8. A batch program scheduling optimization apparatus, characterized by, The method comprises: a directed acyclic graph generation module configured to extract inter-task dependency relationships and resource requirement information of each task from the batch processing program code, and generate a directed acyclic graph for representing the task dependency relationships and the resource requirements; a target scheduling strategy determination module configured to perform scheduling optimization on the directed acyclic graph according to a target agent, to obtain a target scheduling strategy, wherein the target agent is obtained by minimizing the total running time under resource constraints through a reinforcement learning algorithm, and the target scheduling strategy includes execution sequences of all tasks in the directed acyclic graph and resource allocation information of each task; a target scheduling strategy verification module configured to verify the target scheduling strategy in terms of resource constraints, inter-task dependency relationships and running performance, to obtain a target scheduling strategy meeting the requirements.
9. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory connected in communication with the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the batch processing program scheduling optimization method in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions for enabling the processor to perform the batch processing program scheduling optimization method in any one of claims 1-7 when executed.