Resource allocation method and apparatus, and storage medium
Patent Information
- Application Number
- CN202310029024.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-09
- Publication Date
- 2026-09-04
- Estimated Expiration
- 2043-01-09
AI Technical Summary
[0004]本申请提供一种资源分配方法、装置及存储介质,用于解决处理任务效率低的问题
[0018] Fifthly, this application provides a chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run computer programs or instructions to implement the resource allocation method as described in the first aspect and any possible implementation thereof.
Smart Images

Figure CN116126531B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a resource allocation method, apparatus and storage medium. Background Technology
[0002] In the era of big data, with the popularization of computer technology, the number of tasks to be processed on servers (such as running services, models, and data) is increasing exponentially. Furthermore, these tasks may be dependent on each other. For example, a server can obtain result A by processing task A, and the server needs to use result A to process task B; that is, task B depends on task A.
[0003] Currently, when a server processes multiple pending tasks, it can allocate the same processing resources to all tasks and utilize those resources to complete them. However, if the server has not finished processing a dependent task (e.g., task A), even if the dependent task (e.g., task B) obtains processing resources, the server cannot process that dependent task. This leads to a waste of server resources, thereby reducing the server's efficiency in processing pending tasks. Summary of the Invention
[0004] This application provides a resource allocation method, apparatus, and storage medium to solve the problem of low efficiency in processing tasks.
[0005] To achieve the above objectives, this application adopts the following technical solution:
[0006] Firstly, this application provides a resource allocation method. In this method, multiple task statements and multiple sets of preset priority parameters are obtained. The task statements indicate the dependencies between tasks to be processed, and each task corresponds to one task statement and one set of preset priority parameters, which indicate the urgency of the task. Based on each task statement, a first dependency relationship is generated, which includes dependencies between multiple tasks to be processed. Based on the first dependency relationship and the multiple sets of preset priority parameters, a target priority for each task to be processed is determined. Based on the target priority of each task to be processed, resources are allocated to each task; wherein the amount of resources allocated to tasks with higher target priorities is greater than the amount of resources allocated to tasks with lower target priorities.
[0007] Based on the above technical solution, the server obtains multiple task statements and multiple sets of preset priority parameters. The task statements indicate the dependencies between tasks to be processed, with each task corresponding to one task statement and one set of preset priority parameters. The preset priority parameters indicate the urgency of the task. Based on each task statement, the server generates a first dependency relationship, which includes dependencies between multiple tasks. Based on the first dependency relationship and the multiple sets of preset priority parameters, the server determines the target priority of each task. Based on the target priority of each task, the server allocates resources to each task; the resources allocated to tasks with higher target priorities are greater than those allocated to tasks with lower target priorities. This ensures that high-priority tasks receive more resources, guaranteeing a reasonable allocation of resources. Furthermore, it speeds up the processing of high-priority tasks, thereby preventing low-priority tasks from waiting too long and improving the server's processing efficiency.
[0008] In one possible design, multiple second dependencies are generated based on each task statement. Each second dependency corresponds to a task to be processed, and the second dependency is the dependency of the task to be processed corresponding to the second dependency. A first dependency is then generated based on these multiple second dependencies.
[0009] In one possible design, based on the first dependency relationship, the number of dependencies and the dependency level of each pending task are determined, where the number of dependencies is the number of tasks that depend on the pending task. Based on the number of dependencies and the dependency level of each pending task, a first-class priority is determined for each pending task, which is the priority of the pending task among multiple pending tasks. For pending tasks with the same first-class priority, a second-class priority is determined for each pending task based on preset priority parameters, where the second-class priority is the priority of the pending task among pending tasks with the same first-class priority. A set of preset priority parameters includes: preset priority value and preset task time limit. The target priority includes both the first-class priority and the second-class priority.
[0010] In one possible design, the task statements include Structured Query Language (SQL) statements and Extensible Markup Language (XML) statements.
[0011] Secondly, this application provides a resource allocation apparatus, which includes an acquisition unit and a processing unit.
[0012] The acquisition unit acquires multiple task statements and multiple sets of preset priority parameters. The task statements indicate the dependencies between tasks to be processed. Each task corresponds to one task statement and one set of preset priority parameters, which indicate the urgency of the task. The processing unit generates a first dependency relationship based on each task statement. This first dependency relationship includes dependencies between multiple tasks to be processed. The processing unit also determines the target priority of each task to be processed based on the first dependency relationship and the multiple sets of preset priority parameters. Finally, the processing unit allocates resources to each task to be processed based on its target priority; wherein the resources allocated to tasks with higher target priorities are greater than those allocated to tasks with lower target priorities.
[0013] In one possible design, the processing unit is further configured to generate multiple second dependencies based on each task statement, with each second dependency corresponding to a task to be processed, and the second dependency being the dependency of the task to be processed corresponding to the second dependency. The processing unit is also configured to generate first dependencies based on the multiple second dependencies.
[0014] In one possible design, the processing unit is further configured to determine the number and dependency level of each task to be processed based on a first dependency relationship, where the number of dependencies is the number of tasks that depend on the task to be processed. The processing unit is also configured to determine a first-class priority for each task to be processed based on the number and dependency level of each task, where the first-class priority is the priority of the task to be processed among multiple tasks to be processed. The processing unit is further configured to, for tasks to be processed with the same first-class priority, determine a second-class priority for each task to be processed based on preset priority parameters of the tasks to be processed, where the second-class priority is the priority of the task to be processed among tasks with the same first-class priority. A set of preset priority parameters includes: preset priority values and preset task time limits. The target priority includes: the first-class priority and the second-class priority.
[0015] In one possible design, the task statements include Structured Query Language (SQL) statements and Extensible Markup Language (XML) statements.
[0016] Thirdly, this application provides a resource allocation apparatus, which includes: a processor and a memory; the processor and the memory are coupled; the memory is used to store one or more programs, the one or more programs including computer-executable instructions, and when the resource allocation apparatus is running, the processor executes the computer-executable instructions stored in the memory to implement the resource allocation method as described in the first aspect and any possible implementation thereof.
[0017] Fourthly, this application provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the resource allocation method described in the first aspect and any possible implementation thereof.
[0018] Fifthly, this application provides a chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run computer programs or instructions to implement the resource allocation method as described in the first aspect and any possible implementation thereof.
[0019] The technical problems that the resource allocation device, computer equipment, computer storage medium or chip can solve and the technical effects that they can achieve in the above solution can be found in the technical problems and effects solved in the first aspect above, and will not be repeated here. Attached Figure Description
[0020] Figure 1 A flowchart illustrating a resource allocation method provided in an embodiment of this application;
[0021] Figure 2 A flowchart illustrating another resource allocation method provided in an embodiment of this application;
[0022] Figure 3 An example diagram illustrating a task dependency provided in an embodiment of this application;
[0023] Figure 4 A flowchart illustrating another resource allocation method provided in an embodiment of this application;
[0024] Figure 5 A flowchart illustrating another resource allocation method provided in an embodiment of this application;
[0025] Figure 6 This is a schematic diagram of the structure of a resource allocation device provided in an embodiment of this application;
[0026] Figure 7 This is a schematic diagram of another resource allocation device provided in an embodiment of this application;
[0027] Figure 8 A conceptual partial view of a computer program product provided for an embodiment of this application. Detailed Implementation
[0028] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0029] In this article, the character " / " generally indicates that the objects before and after it are in an "or" relationship. For example, A / B can be understood as A or B.
[0030] The terms “first” and “second” in the specification and claims of this application are used to distinguish different objects, rather than to describe a specific order of objects.
[0031] Furthermore, the terms "comprising" and "having," and any variations thereof, used in the description of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or modules is not limited to the steps or modules listed, but may optionally include other steps or modules not listed, or may optionally include other steps or modules inherent to such process, method, product, or device.
[0032] Furthermore, in the embodiments of this application, the words "exemplary" or "for example" are used to indicate that they are examples, illustrations, or descriptions. Any embodiment or design that is described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or design options. Specifically, the use of the words "exemplary" or "for example" is intended to present concepts in a concrete manner.
[0033] In the era of big data, with the popularization of computer technology, the number of tasks to be processed on servers (such as running services, models, and data) is increasing exponentially. Furthermore, these tasks may be dependent on each other. For example, a server can obtain result A by processing task A, and the server needs to use result A to process task B; that is, task B depends on task A.
[0034] Currently, when a server processes multiple pending tasks, it can allocate the same processing resources to all tasks and utilize those resources to complete them. However, if the server has not finished processing a dependent task (such as task A), even if the dependent task (such as task B) obtains processing resources, the server cannot process that dependent task.
[0035] In summary, current technical solutions assign equal priority to all tasks and allocate equal time slices (i.e., resource amounts) to each task. This leads to wasted server resources and reduces the server's efficiency in processing tasks.
[0036] To address the aforementioned problems, this application provides a resource allocation method. A server obtains multiple task statements and multiple sets of preset priority parameters. The task statements indicate the dependencies between tasks to be processed. Each task to be processed corresponds to one task statement and one set of preset priority parameters, which indicate the urgency of the task. Based on each task statement, the server generates a first dependency relationship, which includes dependencies between the multiple tasks to be processed. Based on the first dependency relationship and the multiple sets of preset priority parameters, the server determines the target priority of each task to be processed. Based on the target priority of each task to be processed, the server allocates resources to each task to be processed; wherein the amount of resources allocated to tasks with higher target priorities is greater than the amount of resources allocated to tasks with lower target priorities.
[0037] Understandably, the server obtains multiple task statements and multiple sets of preset priority parameters. The task statements indicate the dependencies between tasks to be processed. Each task corresponds to one task statement and one set of preset priority parameters, which indicate the urgency of the task. Based on each task statement, the server generates a first dependency relationship, which includes the dependencies between multiple tasks. Based on the first dependency relationship and the preset priority parameters, the server determines the target priority of each task. Based on the target priority of each task, the server allocates resources to each task; the resources allocated to tasks with higher target priorities are greater than those allocated to tasks with lower target priorities. This ensures that high-priority tasks receive more resources, guaranteeing a reasonable allocation of resources. Furthermore, it speeds up the processing of high-priority tasks, thereby preventing low-priority tasks from waiting too long and improving the server's processing efficiency.
[0038] It should be noted that the server can be a single physical server, or a server cluster consisting of multiple servers. Alternatively, the server cluster can be a distributed cluster. Alternatively, the server can be a cloud server. This application does not limit the specific implementation of the server.
[0039] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0040] like Figure 1The image shows a resource allocation method provided in an embodiment of this application. The method includes:
[0041] S101. The server obtains multiple task statements and multiple sets of preset priority parameters.
[0042] The task statement is used to indicate the dependencies of the tasks to be processed. One task corresponds to one task statement and a set of preset priority parameters. The preset priority parameters are used to indicate the urgency of the tasks to be processed.
[0043] In one possible design, a task statement includes: a Structured Query Language (SQL) statement and an Extensible Markup Language (XML) statement.
[0044] It should be noted that SQL statements can include the data table to be processed. XML statements include: the task identifier of the task to be processed, and the task identifiers of other tasks that depend on this task.
[0045] For example, the SQL statement for task A may include: table A, table B, and table C. The XML statement for task A includes: task B depends on task A (i.e., a task to be processed that depends on task A). Optionally, the XML statement for task A may also include: task A depends on task C (i.e., a task to be processed that task A depends on).
[0046] In one possible design, a set of preset priority parameters may include at least one of the following: a preset priority value and a preset task time limit, wherein the preset task time limit is used to indicate the duration for completing the pending task.
[0047] For example, task a can have a preset priority of 1 and a preset time limit of 10 hours. Task b can have a preset priority of 2 and a preset time limit of 1 hour. Task c can have a preset priority of 3 and a preset time limit of 3 hours.
[0048] It should be noted that the preset priority value and preset task time limit can be set by the developers.
[0049] In some embodiments, the server can obtain multiple tasks to be processed, and obtain the task statement and a set of preset priority parameters corresponding to each task to be processed.
[0050] For example, such as Figure 2 As shown, the server can use its automatic collection capability to gather all pending tasks on the server, obtaining an initial task set. Then, the server sets the target priority of each pending task in the initial task set to a preset priority (e.g., -1), resulting in an initial priority table.
[0051] S102. The server generates the first dependency relationship based on each task statement.
[0052] The first dependency relationship includes the dependency relationship between multiple tasks to be processed.
[0053] For example, the first dependency can be represented by a directed graph. For instance, as shown below... Figure 3 As shown, the multiple tasks to be processed include: Task 0, Task 1, Task 2, Task 3, Task 4, Task 5, and Task 6. Among them, Task 2, Task 4, and Task 5 all depend on Task 0, Task 4 depends on Task 0, Task 2, and Task 1, and Task 5 depends on Task 0, Task 4, and Task 1. Task 6 does not depend on any of them.
[0054] In one possible implementation, the server can generate multiple second dependencies based on each task statement. Each second dependency corresponds to a task to be processed, and the second dependency is the dependency of the task to be processed corresponding to the second dependency.
[0055] In one possible design, the server can parse each task statement to obtain the SQL and XML statements. Then, for each task statement, the server can parse the SQL and XML statements based on regular expressions to generate the first syntax tree corresponding to the task statement.
[0056] For example, the server can use regular expressions to parse SQL statements and obtain the table names following the INSERT, CREATE, UPDATE, and MERGE INTO keywords, using these as parent nodes. Then, the server can obtain the table names following the FROM and JOIN keywords, using these as child nodes. The server then repeats the above process, using the child nodes as the next level of parent nodes, recursively generating the first syntax tree.
[0057] For example, if the SQL statement for task a includes a statement to create table a (e.g., statement a) and a statement to use table a (e.g., statement b), then statement a depends on statement b. If the XML statement for task a includes a statement that task a depends on task b, then the second dependency of task a is task a depends on task b.
[0058] Then, the server can generate the first dependency based on multiple second dependencies.
[0059] In one possible design, the server generates a second syntax tree based on the first syntax tree for each task statement. This second syntax tree is composed of multiple first syntax trees. The server then expands the second syntax tree by adding key nodes to obtain the final syntax tree. Finally, based on the final syntax tree, the server generates a directed graph of data sourcing, which represents the first dependency relationship.
[0060] S103. The server determines the target priority of each task to be processed based on the first dependency relationship and multiple sets of preset priority parameters.
[0061] In one possible implementation, the server determines the number of dependencies for each pending task based on the first dependency relationship. Then, the server determines the target priority for each pending task based on the number of dependencies and a preset priority value.
[0062] In another possible implementation, the target priority includes: a first type of priority and a second type of priority. The first type of priority is the priority of the task to be processed among multiple tasks to be processed, and the second type of priority is the priority of the task to be processed among tasks with the same first type of priority.
[0063] like Figure 4 As shown, this is a resource allocation method provided in an embodiment of the present application. In this method, S103 may include:
[0064] S401. Based on the first dependency relationship, the server determines the number of dependencies and the dependency level of each task to be processed.
[0065] The number of dependents is the number of tasks that depend on the task to be processed.
[0066] For example, in combination Figure 3 Task 0 has 3 dependencies, and Task 3 has 0 dependencies. Tasks 0, 1, and 6 are in the first level, Task 2 is in the second level, Tasks 3 and 4 are in the third level, and Task 5 is in the fourth level.
[0067] Optionally, the server can determine the number of dependencies for each pending task based on the first dependency relationship, where the number of dependencies is the number of pending tasks that the pending task depends on.
[0068] For example, in combination Figure 3 Task 0 has 0 dependencies, and Task 2 has 1 dependency.
[0069] S402. The server determines the first priority of each pending task based on the number of dependencies and the dependency level of each pending task.
[0070] The first priority category is the priority of the task to be processed among multiple tasks to be processed.
[0071] For example, combining Figure 3 Table 1 shows Figure 3 The first priority category for each task.
[0072] Table 1
[0073] 1 0、1、6 2 2、3 3 4、5
[0074] In other words, the first priority of tasks 0, 1 and 6 is 1, the first priority of tasks 2 and 3 is 2, and the first priority of tasks 4 and 5 is 3. The first priority of 1 is higher than the first priority of 2, and the first priority of 2 is higher than the first priority of 3.
[0075] In one possible implementation, for each task to be processed, the server can compare the number of dependencies of the task with at least one preset threshold to obtain a first sub-priority of the task, with different preset thresholds corresponding to different first sub-priorities. The server then compares the dependency level of the task with a preset level threshold to obtain a second sub-priority of the task, with different preset level thresholds corresponding to different second sub-priorities. Finally, the server determines the first priority category of the task based on the first and second sub-priorities.
[0076] S403. For tasks with the same first priority, the server determines the second priority of each task based on the preset priority parameters of the tasks.
[0077] The second priority category is the priority of the task to be processed among the tasks of the same first priority category. A set of preset priority parameters includes: preset priority value and preset task time limit.
[0078] In one possible implementation, the server can normalize the preset priority value to obtain a processed preset priority value. Then, the server processes the preset task time limit to obtain the time limit urgency. Next, the server determines the second priority category of the task to be processed based on the processed preset priority value, the time limit urgency, a first weight, and a second weight. Here, the first weight is the weight of the processed preset priority value, and the second weight is the weight of the time limit urgency.
[0079] In one possible design, the server can determine a first priority value for each pending task based on its preset priority value. This first priority value is the sum of the preset priority values of all pending tasks. Then, for each pending task's preset priority value, the server normalizes the preset priority value according to the first priority value and the preset priority value, obtaining a processed preset priority value.
[0080] Optionally, the processed preset priority value can be represented by Formula 1.
[0081]
[0082] Where, ρ iZ is used to represent the preset priority value of the i-th task out of n tasks after processing. i A preset priority value, z, is used to identify the i-th task to be processed. j The preset priority value is used to represent the j-th task to be processed, where i, j, and n are all positive integers.
[0083] Optionally, the urgency of the time limit can be expressed by Formula 2.
[0084]
[0085] Among them, t i T is used to represent the urgency of the time limit for the i-th pending task. i This is used to represent the preset task time limit for the i-th pending task.
[0086] In one possible design, the second priority of the task to be processed can be represented by Formula 3.
[0087] Pi = α·ρ i +β·t i Formula 3.
[0088] Where Pi represents the second priority of the i-th task to be processed, α represents the first weight, and β represents the second weight.
[0089] It should be noted that the embodiments of this application do not limit the first weight and the second weight. For example, the first weight can be 0.6 and the second weight can be 0.4.
[0090] S104. The server allocates resources to each pending task based on the target priority of each pending task.
[0091] Among them, the amount of resources allocated to pending tasks with high target priority is greater than the amount of resources allocated to pending tasks with low target priority.
[0092] In one possible design, the target priorities include: a first-class priority. The server can compare the first-class priorities of each pending task to determine at least one task set, with each task set corresponding to a priority level. Then, the server can allocate resources to the pending tasks based on the priorities corresponding to the task sets.
[0093] For example, referring to Table 1, the amount of resources allocated by the server to tasks 0, 1, and 6 is more than the amount of resources allocated to tasks 2 and 3.
[0094] In another possible design, the target priority includes two categories: a first-class priority and a second-class priority. The server can compare the first-class priorities of each task to determine at least one task set, with each task set corresponding to a priority level. Then, for each task set, the server sorts the tasks according to their second-class priorities and allocates resources to them.
[0095] For example, referring to Table 1, if the second priority of task 0 is higher than the second priority of task 1, then the server allocates more resources to task 0 than to task 1.
[0096] Understandably, the server obtains multiple task statements and multiple sets of preset priority parameters. The task statements indicate the dependencies between tasks to be processed. Each task corresponds to one task statement and one set of preset priority parameters, which indicate the urgency of the task. Based on each task statement, the server generates a first dependency relationship, which includes the dependencies between multiple tasks. Based on the first dependency relationship and the preset priority parameters, the server determines the target priority of each task. Based on the target priority of each task, the server allocates resources to each task; the resources allocated to tasks with higher target priorities are greater than those allocated to tasks with lower target priorities. This ensures that high-priority tasks receive more resources, guaranteeing a reasonable allocation of resources. Furthermore, it speeds up the processing of high-priority tasks, thereby preventing low-priority tasks from waiting too long and improving the server's processing efficiency.
[0097] In some embodiments, the server stores the target priorities of historical task statements. After the server retrieves multiple task statements, it can determine whether multiple task statements exist in the historical task statements. If multiple task statements exist in the historical task statements, the server does not need to retrieve the first type of priority.
[0098] For example, such as Figure 5 As shown, the server can retrieve all pending tasks, obtaining a task set. Then, the server can determine whether it stores the target priority for each pending task. If the target priority is stored, the server transmits the pending tasks to the distributed big data platform for processing. If the target priority is not stored, the server transmits the pending tasks to the priority allocation system. The priority allocation system then transmits the pending tasks to the distributed big data platform.
[0099] In some embodiments, the server may obtain the historical processing time and current processing time of the task to be processed. Then, the server determines the efficiency improvement ratio based on the historical and current processing times of the task.
[0100] In one possible design, the efficiency improvement ratio can be expressed by Equation 4.
[0101]
[0102] Where μ represents the efficiency improvement ratio, T represents the sum of the historical processing times of all tasks to be processed, and m i n is used to represent the historical start time of the i-th pending task. i Used to indicate the current start time of the i-th task to be processed.
[0103] The foregoing primarily describes the solutions provided in the embodiments of this application from the perspective of computer devices. It is understood that, in order to achieve the aforementioned functions, the computer device includes corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should readily recognize that, based on the resource allocation methods and steps described in conjunction with the embodiments disclosed in this application, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0104] This application also provides a resource allocation device. This resource allocation device can be a computer device, a CPU within the aforementioned computer device, a processing module within the aforementioned computer device for allocating resources, or a client within the aforementioned computer device for allocating resources.
[0105] This application embodiment can divide resource allocation into functional modules or functional units based on the above method examples. For example, each function can be divided into its own functional modules or functional units, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module or functional unit. The module or unit division in this application embodiment is illustrative and represents only one logical functional division; other division methods may be used in actual implementation.
[0106] like Figure 6 The diagram shown is a structural schematic of a resource allocation device provided in an embodiment of this application. The resource allocation device is used to perform... Figure 1 or Figure 4The resource allocation method shown. The resource allocation device may include an acquisition unit 601 and a processing unit 602.
[0107] The acquisition unit 601 is used to acquire multiple task statements and multiple sets of preset priority parameters. The task statements indicate the dependencies between tasks to be processed. Each task to be processed corresponds to one task statement and one set of preset priority parameters, which indicate the urgency of the task. The processing unit 602 is used to generate a first dependency relationship based on each task statement. The first dependency relationship includes dependencies between multiple tasks to be processed. The processing unit 602 is also used to determine the target priority of each task to be processed based on the first dependency relationship and the multiple sets of preset priority parameters. The processing unit 602 is also used to allocate resources to each task to be processed based on its target priority; wherein the amount of resources allocated to tasks with higher target priorities is greater than the amount of resources allocated to tasks with lower target priorities.
[0108] In one possible design, processing unit 602 is further configured to generate multiple second dependencies based on each task statement, where each second dependency corresponds to a task to be processed, and the second dependency is the dependency of the task to be processed corresponding to the second dependency. Processing unit 602 is also configured to generate a first dependency based on the multiple second dependencies.
[0109] In one possible design, processing unit 602 is further configured to determine the number and dependency level of each task to be processed based on a first dependency relationship, wherein the number of dependencies is the number of tasks that depend on the task to be processed. Processing unit 602 is also configured to determine a first-class priority for each task to be processed based on the number and dependency level of each task to be processed, wherein the first-class priority is the priority of the task to be processed among multiple tasks to be processed. Processing unit 602 is further configured to, for tasks to be processed with the same first-class priority, determine a second-class priority for each task to be processed based on preset priority parameters of the tasks to be processed, wherein the second-class priority is the priority of the task to be processed among tasks with the same first-class priority, and a set of preset priority parameters includes: preset priority value and preset task time limit. The target priority includes: the first-class priority and the second-class priority.
[0110] In one possible design, the task statements include Structured Query Language (SQL) statements and Extensible Markup Language (XML) statements.
[0111] Figure 7 This is a schematic diagram of the hardware structure of a resource allocation device according to an exemplary embodiment. The resource allocation device may include a processor 702, which is used to execute application code to implement the resource allocation method of this application.
[0112] The processor 702 may be a central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits used to control the execution of the program of the present application.
[0113] like Figure 7 As shown, the resource allocation device may further include a memory 703. The memory 703 stores the application code that executes the scheme of this application, and its execution is controlled by the processor 702.
[0114] Memory 703 may be a read-only memory (ROM) or other type of static storage device capable of storing static information and instructions, random access memory (RAM) or other type of dynamic storage device capable of storing information and instructions, or electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital versatile optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto. Memory 703 may exist independently and be connected to processor 702 via bus 704. Memory 703 may also be integrated with processor 702.
[0115] like Figure 7 As shown, the resource allocation device may further include a communication interface 701, wherein the communication interface 701, processor 702, and memory 703 may be coupled to each other, for example, through a bus 704. The communication interface 701 is used for information interaction with other devices, for example, supporting information interaction between the resource allocation device and other devices.
[0116] It should be pointed out that, Figure 7 The equipment structure shown does not constitute a limitation on the equipment for allocating this resource, except Figure 7 In addition to the components shown, the resource allocation device may include more or fewer components than illustrated, or combine certain components, or have different component arrangements.
[0117] In actual implementation, the functions implemented by the processing unit 602 can be derived from... Figure 7 The processor 702 shown calls the program code in memory 703 to implement this.
[0118] This application also provides a computer-readable storage medium storing instructions that, when executed by a processor of a computer device, enable the computer to perform the resource allocation method provided in the embodiments described above. For example, the computer-readable storage medium may be a memory 703 including instructions, which may be executed by a processor 702 of a computer device to complete the method. Optionally, the computer-readable storage medium may be a non-transitory computer-readable storage medium, such as a ROM, RAM, CD-ROM, magnetic tape, floppy disk, or optical data storage device.
[0119] Figure 8 A conceptual partial view of a computer program product provided in an embodiment of this application is shown schematically. The computer program product includes a computer program for executing computer processes on a computing device.
[0120] In one embodiment, the computer program product is provided using a signal bearer medium 800. The signal bearer medium 800 may include one or more program instructions that, when executed by one or more processors, can provide the above-mentioned... Figure 1 , Figure 4 The described function or part of the function. Therefore, for example, refer to... Figure 1 In the embodiment shown, one or more features of S101 to S104 can be fulfilled by one or more instructions associated with the signal carrying medium 800. Furthermore, Figure 8 The program instructions in the document also describe example instructions.
[0121] In some examples, the signal carrying medium 800 may include a computer-readable medium 801, such as, but not limited to, a hard disk drive, a compact disc (CD), a digital video disc (DVD), a digital magnetic tape, a memory, a read-only memory (ROM), or a random access memory (RAM), etc.
[0122] In some implementations, the signal carrying medium 800 may include a computer recordable medium 802, such as, but not limited to, a memory, a read / write (R / W) CD, a R / W DVD, and so on.
[0123] In some implementations, the signal carrying medium 800 may include a communication medium 803, such as, but not limited to, digital and / or analog communication media (e.g., fiber optic cables, waveguides, wired communication links, wireless communication links, etc.).
[0124] The signal-bearing medium 800 can be transmitted by a wireless communication medium 803. One or more program instructions can be, for example, computer-executable instructions or logical implementation instructions.
[0125] In some examples, such as targeting Figure 6 The described resource allocation apparatus can be configured to provide various operations, functions, or actions in response to one or more program instructions in a computer-readable medium 801, a computer-recordable medium 802, and / or a communication medium 803.
[0126] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0127] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0128] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the constituent units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0129] Furthermore, the functional units in the various embodiments of 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. The integrated unit can be implemented in hardware or as a software functional unit.
[0130] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, essentially, or the part that contributes to the prior art, or a complete or partial classification of the technical solution, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of 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, ROM, RAM, magnetic disks, or optical disks.
[0131] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A resource allocation method, characterized in that, The method includes: Obtain multiple task statements and multiple sets of preset priority parameters. The task statements are used to indicate the dependencies between tasks to be processed. Each task to be processed corresponds to one task statement and one set of preset priority parameters. The preset priority parameters are used to indicate the urgency of the task to be processed. The SQL statements in the task statements are parsed using regular expressions to obtain the table names after the keywords to determine the parent and child nodes, and the first syntax tree corresponding to each task to be processed is generated recursively. Based on each of the first syntax trees, a second dependency relationship is determined for each of the tasks to be processed, and one second dependency relationship corresponds to one task to be processed. The second dependency relationship is the dependency relationship of the task to be processed corresponding to the second dependency relationship. Based on the multiple second dependencies, a first dependency is generated, the first dependency including: the dependency between the multiple tasks to be processed; Based on the first dependency relationship and the multiple sets of preset priority parameters, the target priority of each task to be processed is determined; Based on the target priority of each task to be processed, resources are allocated to each task to be processed; wherein the amount of resources allocated to the task to be processed with a higher target priority is greater than the amount of resources allocated to the task to be processed with a lower target priority.
2. The method according to claim 1, characterized in that, The step of determining the target priority of each task to be processed based on the first dependency relationship and the multiple sets of preset priority parameters includes: Based on the first dependency relationship, the number of dependencies and the dependency level of each task to be processed are determined, wherein the number of dependencies is the number of tasks that depend on the task to be processed. Based on the number of dependencies and the dependency level of each task to be processed, a first priority category is determined for each task to be processed. The first priority category is the priority of the task to be processed among multiple tasks to be processed. For tasks with the same priority in the first category, a second priority is determined for each task based on the preset priority parameters of the task. The second priority is the priority of the task among tasks with the same priority in the first category. A set of preset priority parameters includes: preset priority value and preset task time limit. The target priority includes: the first type of priority and the second type of priority.
3. The method according to claim 1, characterized in that, The task statements include Structured Query Language (SQL) statements and Extensible Markup Language (XML) statements.
4. A resource allocation device, characterized in that, The device includes: The acquisition unit is used to acquire multiple task statements and multiple sets of preset priority parameters. The task statements are used to indicate the dependencies of the tasks to be processed. One task to be processed corresponds to one task statement and one set of preset priority parameters. The preset priority parameters are used to indicate the urgency of the task to be processed. The processing unit is used to parse the SQL statement in the task statement using regular expressions, obtain the table name after the keyword to determine the parent node and child node, and recursively generate the first syntax tree corresponding to each task to be processed. The processing unit is further configured to determine a second dependency relationship corresponding to each of the tasks to be processed based on each of the first syntax trees, wherein one second dependency relationship corresponds to one task to be processed, and the second dependency relationship is the dependency relationship of the task to be processed corresponding to the second dependency relationship; The processing unit is further configured to generate a first dependency relationship based on a plurality of second dependency relationships, wherein the first dependency relationship includes: dependency relationships between a plurality of tasks to be processed; The processing unit is further configured to determine the target priority of each of the tasks to be processed based on the first dependency relationship and the multiple sets of preset priority parameters; The processing unit is further configured to allocate resources to each task to be processed based on the target priority of each task to be processed; wherein the amount of resources allocated to the task to be processed with a higher target priority is greater than the amount of resources allocated to the task to be processed with a lower target priority.
5. The apparatus according to claim 4, characterized in that, The processing unit is further configured to determine the number of dependencies and the dependency level of each task to be processed based on the first dependency relationship, wherein the number of dependencies is the number of tasks that depend on the task to be processed. The processing unit is further configured to determine a first priority for each task to be processed based on the number of dependencies and the dependency level of each task to be processed, wherein the first priority is the priority of the task to be processed among the multiple tasks to be processed. The processing unit is further configured to, for the pending tasks with the same first priority, determine the second priority of each pending task based on the preset priority parameters of the pending tasks. The second priority is the priority of the pending task among the pending tasks with the same first priority. The set of preset priority parameters includes: preset priority value and preset task time limit. The target priority includes: the first type of priority and the second type of priority.
6. The apparatus according to claim 4, characterized in that, The task statements include Structured Query Language (SQL) statements and Extensible Markup Language (XML) statements.
7. A resource allocation device, characterized in that, include: Processor and memory; The processor and the memory are coupled; The memory is used to store one or more programs, the one or more programs including computer-executable instructions, and when the resource allocation device is running, the processor executes the computer-executable instructions stored in the memory to cause the resource allocation device to perform the method as described in any one of claims 1-3.
8. A computer-readable storage medium storing instructions, characterized in that, When the computer executes the instruction, the computer performs the method as described in any one of claims 1-3.
Citation Information
Patent Citations
Task scheduling method and device
CN113391886A
Task dispatching method and apparatus
WO2021180092A1